【发布时间】:2012-06-06 03:39:06
【问题描述】:
假设我有以下实体:
Public Class Dodo
Public Property ID As Integer
Public Property Name As String
Public Overridable Property Mother As DodoMother
End Class
Public Class DodoMother
Public Property ID As Integer
Public Property Name As String
Public Property Age As Integer
End Class
我需要能够在设置后将 Dodo.Mother 设置为空。
即
Dim ndodo as dodo = db.Dodos.find(1)
ndodo.Mother = nothing
db.SaveChanges()
当我执行上述代码时,我没有收到错误或异常或任何表明该语句无效的情况。 ndodo 对象似乎没有将 Mother 设置为 null,并且 DB 没有得到更新。
我做错了吗? 我也尝试添加 db.Entry(ndodo).State = EntityState.Modified 但这也不起作用。
【问题讨论】:
标签: asp.net-mvc vb.net asp.net-mvc-3 entity-framework