是否有可能有一个外键作为主键? 如果是这样,有人可以帮我用我的代码?ASP.NET MVC - 外键作为主键?
<Key()>
Public Property AssignmentID() As Integer
<ForeignKey("AssignmentID")>
Public Overridable Property Assignment As Assignment
Public Overridable Property User As User
对于上面我的代码得到一个错误:
One or more validation errors were detected during model generation:
System.Data.Edm.EdmAssociationEnd: : Multiplicity is not valid in Role 'AssignmentLocks_Assignment_Source' in relationship 'AssignmentLocks_Assignment'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be �1�.
我试图创建具有一个(或无)每分配记录的表。
这与MVC无关。 –