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) –