如果我有Book对象具有子集合的评论,我可以用实体框架更新书籍和评论列表吗?实体框架4.1修改对象和子集合
我曾尝试:
_context.Books.Attach(book);
_context.ObjectStateManager.ChangeObjectState(book, EntityState.Modified);
_context.SaveChanges();
,没有运气...
得到第一线以下错误:
An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key
“没有运气”不是很具描述性。当你尝试时,究竟会发生什么? – 2011-04-28 17:04:28
我收到错误:'ObjectStateManager中已存在具有相同键的对象。 ObjectStateManager无法使用同一个键“ – stephen776 2011-04-28 17:12:47
”跟踪多个对象在哪条线上? “附加”行? – 2011-04-28 17:17:25