c# - An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy -


i hope can me. issue have been battling days now, , struggling resolve it.

i have read quite bit on specific error, , seems there couple ways resolve it. have unfortunately not been able to.

my error lies on line:

sourcecontext.projectmasters.attach(project, true); 

i error: entity can attached modified without original state if declares version member or not have update check policy.

i have read , tried (where possible) following solutions:

entity attachment issues in linq

update check' issue when updating entity using datacontext attach method

system.invalidoperationexception: entity can attached modified

and more ...

it seems problem lies in this; not updating unchanged record. however, far can see , understand, record changed.

i sure simple doing wrong, , perhaps need set of new eyes on it.

please remember; newbie :) thank patience.

  private class projectmastersidentifier             {                 public int id { get; set; }                 public string financeprojectnumber { get; set; }                 public string processingsignal { get; set; }             }          public static void processinstructions()         {             using (var sourcecontext = new stagingtabledatacontext())             {                 using (var destinationcontext = new destinationtabledatacontext())                 {                     var allprojectnames = destinationcontext.theoptions.select(u => u.name).distinct().tolist();                      var instructiongroups = sourcecontext.projectmasters.                         where(u => u.processing_result == unprocessed).                         select(                         u =>                             new projectmastersidentifier                             {                                 id = u.rowid,                                 financeprojectnumber = u.finance_project_number,                                 processingsignal = u.processing_signal.trim()                             }                         ).groupby(u => u.processingsignal.trim());                      foreach (var instructiongroup in instructiongroups.where(u => u.key == "i"))                     {                         foreach (var instruction in instructiongroup)                         {                             if (allprojectnames.contains(instruction.financeprojectnumber))                             {                                 var project = new projectmaster                                 {                                     rowid = instruction.id,                                     processing_result = invalid,                                     processing_result_text = "project exists"                                 };                                 sourcecontext.projectmasters.attach(project, true);                             }                             else                             {                                 var project = new projectmaster                                 {                                     rowid = instruction.id,                                     processing_result = unprocessed,                                     processing_result_text = "project not exiist...moving on."                                 };                                 sourcecontext.projectmasters.attach(project, true);                             }                         }                  sourcecontext.submitchanges();             }         }     } 

thank in advance!


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -