我一直在努力解決這個問題幾天了,我仍然無法弄清楚。我已經創建了一個示例項目,希望能幫助解決這個問題。主要問題是,當我從我的上下文加載用戶並在此對象上執行UpdateModel()時,似乎刪除了我的實體引用,並在子對象中獲得空引用。CTP 5 EF代碼第一次UpdateModel()
以下是錯誤:
The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted
。
這裏是鏈接到代碼: Here(第42行,導致發生錯誤)
請勿使用UpdateModel – Omu 2011-03-11 19:06:43
當我更新子對象集合時,您會有什麼建議? – 2011-03-11 19:13:51
先做手動,之後你可能會尋找一種方法使其具有通用性 – Omu 2011-03-11 21:44:00