我使用的是實體framwork和MVC 4(asp.net)一databasefirst方法和現在要做的,然後得到以下錯誤:實體framwork更好的錯誤解釋
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.
大多數likly我有一個無意的空引用來自於轉換步驟的任何部分(從視圖,視圖模型到通過自動映射器的數據庫對象)。
我想知道的是,如果有一些方法來獲取信息的問題是哪個外鍵導致問題。我試圖追蹤數據庫,但似乎應用程序知道之前試圖保存到數據庫,有問題。我可以以某種方式調試嗎?獲取更多錯誤信息?
丟失數據庫根本就不是解決方案,因爲您丟失了所有數據。相反,您必須通過更新或刪除預約來制定新約束的舊數據。 – Alejandro