我在EF Code First 4.3中针对SqlCe4.0客户端创建数据库时遇到循环引用错误。为了清楚起见,我附上了我想要的数据库模式的图片。仅供参考,我已在SQL Server 2008中成功创建了所需的架构。
参照关系将导致不允许循环引用。 [约束名称= FK_Routes_Seasons_SeasonID]
我的代码是:
Public Class Route
Public Property RouteID as Integer
Public Property SeasonID as Integer
Public Overridable Property Season As Season
Public Overridable Property Contracts As ICollection(Of Contract)
End Class
Public Class Season
Public Property SeasonID as Integer
Public Overridable Property Routes As ICollection(Of Routes)
Public Overridable Property Contracts As ICollection(Of Contract)
End Class
Public Class Contract
Public Property ContractID As Integer
Public Property RouteID As Integer
Public Overridable Property Route As Route
Public Property SeasonID As Integer
Public Overridable Property Season As Season
End Class
答案 0 :(得分:2)