实体框架4.0:错误113:多重性在角色中无效 [英] Entity Framework 4.0: Error 113: Multiplicity is not valid in Role

查看:374
本文介绍了实体框架4.0:错误113:多重性在角色中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的数据库中放置了一个新的表,有4个表与外键有关系。
我以为我以同样的方式配置了所有4,但是我收到这个错误;


错误15错误113:多重性在关系'FK_OtherLeaves_ReportCellImages'中的角色'ReportCellImage'中无效。因为从属角色中的所有属性都为空,所以主体角色的多重性必须为0..1。


所以简化我的表;



ReportCellImage表包含
ReportCellImageId字段在主键和整数中



OtherLeave表包含
ReportCellImageId字段作为可空的外键,默认值为4



其他表格相似,都有配置为与ReportCellImage表格结合的外键。



这是最近的更改,所以当我从数据库更新我的edmx文件时,为什么要得到这个错误,我该如何解决?

解决方案

如果您的FK为空,则主体实体的多重性必须为0..1 - 默认值在此方面没有任何作用,因为您可以为FK分配null。所以所有的依赖实体必须与您的主体实体的0..1 - *关系。


I have put a new table in my database and there are 4 tables that have a foreign key relationship with it. I thought I configured all 4 in the same way, but I get this error;

Error 15 Error 113: Multiplicity is not valid in Role 'ReportCellImage' in relationship 'FK_OtherLeaves_ReportCellImages'. Because all the properties in the Dependent Role are nullable, multiplicity of the Principal Role must be '0..1'.

So to simplify my tables;

ReportCellImage table contains the ReportCellImageId field which in the primary key and an integer

OtherLeave table contains the ReportCellImageId field as a nullable foreign key with a default of 4

The other tables are similar and all have a foreign key configured to join with the ReportCellImage table

This is a recent change, so when I update my edmx file from the database, why do I get this error and how do I fix it?

解决方案

If your FK is nullable your multiplicity in principal entity must be 0..1 - default value has no role in this because you can assign null to FK. So all your dependent entities must be in 0..1 - * relation with your principal entity.

这篇关于实体框架4.0:错误113:多重性在角色中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆