问题
I'm used to using code first where I can do:
db.Users.Attach(user);
db.Entry(user).Property(propertyName).IsModified = true;
How do I do this with a DataModel approach?
I do not have the Entry
method on my datacontext.
回答1:
Use:
context.Users.Attach(user);
ObjectStateEntry entry = context.ObjectStateManager.GetObjectStateEntry(user);
entry.SetModifiedProperty(propertyName);
来源:https://stackoverflow.com/questions/6947950/entity-framework-4-update-specific-properties