问题
OK. I have turned off AutoDetectChangesEnabled, and when I query the context, modify an entity and attempt to save changes, nothing gets updated. I would expect that.
But when I mark the entity as modified, I would expect it to change.
Any ideas?
I am using the UnitOfWork, Repository, Service pattern.
If I enable AutoDetectChangesEnabled then all is fine.
What is the standard way to persist changes to attached objects?
What about detached objects?
Thanks in advance, Sam
回答1:
It's not just entities what is tracked, but relations as well.
ObjectContext.ObjectStateManager
.ChangeRelationshipState(resolution, resolution.Message, r => r.Message, EntityState.Added);
来源:https://stackoverflow.com/questions/6977609/ef-4-1-dbcontext-autodetectchangesenabled