EF 4.1 DBContext AutoDetectChangesEnabled

天大地大妈咪最大 提交于 2019-12-11 01:17:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!