3
对于下面的代码的实体,收到消息:不能附加已经存在
不能附加已经存在的实体。
C#代码:
var con = (from c in cmsContentTable where c.ContentName == contentId select c).FirstOrDefault();
cmsContentTable.Attach(con);
con.ContentData = "New Value";
cmsContentTable.Context.SubmitChanges();
为什么给这个错误 - 这是因为骗子参考已经取得 时
var con = (from c in cmsContentTable where c.ContentName == contentId select c).FirstOrDefault();
做?
如何为您的ORM框架添加标签? – CodesInChaos
可能重复[无法附加已存在的实体](http://stackoverflow.com/questions/2605657/cannot-attach-an-entity-that-already-exists) –