C# 实体框架关联一对多错误

C# 实体框架关联一对多错误,c#,.net,vb.net,visual-studio-2010,entity-framework,C#,.net,Vb.net,Visual Studio 2010,Entity Framework,有人能告诉我为什么我会犯这个错误吗?我曾尝试添加约束,但它会导致大量其他错误,我无法解决。在我看来一切都很好:\ 这就是我得到的错误 Error 1 Error 3003: Problem in mapping fragments starting at line 265:Given the cardinality of Association End Member Contact, it should be mapped to key columns of the table tbl_

有人能告诉我为什么我会犯这个错误吗?我曾尝试添加约束,但它会导致大量其他错误,我无法解决。在我看来一切都很好:\

这就是我得到的错误

Error   1   Error 3003: Problem in mapping fragments starting at line 265:Given the cardinality of Association End Member Contact, it should be mapped to key columns of the table tbl_Contact_Relationship. Either fix the mapping or change the multiplicity of this end.


提前感谢。

修复了此问题,不知道如何解决。删除了tbl_联系人关系,并将其添加回,现在可以正常工作。

这里的问题是,您认为是“1对多”,但实际上是“0或1对多”

您可以在.edmx图表设计器中对此进行修改,或者如果您在数据库中正确设置了外键(请确保在退出对话框窗口后保存表)和“从数据库更新模型”,则会自动更正映射