當前是myclass的新實例和context.classRepo.bringcontentwithid(userid)返回它的一個實例。我將這個值賦給我的新對象current,然後嘗試插入我的數據表中的新行,但它給了我錯誤,如「屬性'ID'是對象的關鍵信息的一部分,不能修改」Entitiy插入數據。「屬性'ID'是對象的關鍵信息的一部分,不能修改」錯誤
其點我不明白是我不想修改任何東西,我只是嘲笑一個實例make chenges並將其作爲新數據插入它。
我該如何解決這個問題?
myclass current = new myclass();
current = context.classRepo.bringcontentwithid(userid);
if (current != null)
{
current.id = context.classRepo.YeniBildirimIdGetir();
current.GONDERILDI = "1";
context.classRepo.Insert(current);
謝謝我做到了:) – TyForHelpDude
[DatabaseGenerated(D atabaseGeneratedOption.Assign)] 沒有這樣的屬性叫做assign。有3個屬性「計算,身份,無」我嘗試了所有這些,但它沒有奏效。 –
@ShalinJirawla:我有同樣的問題,但我使用SQLite。你在用什麼? – newenglander