当我运行我的应用程序并单击特定按钮时,出现错误:
"The "X" property on "Y" could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'."
很酷,所以我转到我的Entity项目,转到Y表,找到X列,右键单击并转到X的属性,然后将Nullable设置为False。
我在SQL中验证,在Y表中,X设置为允许空值,并且确实如此。
然后,我回到我的Entity项目,将Nullable设置为True,保存并构建,我收到:
Error 3031: Problem in mapping fragments starting at line 4049:Non-nullable column "X" in table "Y" is mapped to a nullable entity property.
我听说从.edmx文件中删除表,然后重新添加它是有可能的,但是从未这样做过,并且对所涉及的含义不甚了解。
我听说它可能在 View 中,也可能在存储过程中...
也听说这是一个错误。
有谁遇到过这种情况,找到了“全面解决方案”,或者找到了在哪里寻找此错误的某种路线图?
谢谢!
最佳答案
"The "X" property on "Y" could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'."
在EDMX中,如果转到Y表下方,然后单击X列,请右键单击,单击“属性”,向下滚动到
Nullable
,然后从False
更改为True
。如果出现“映射片段”错误,则必须从EDMX中删除该表并重新添加它,因为在模型浏览器中,它存储表属性以及刷新该属性的唯一方法(我知道)是从“模型浏览器”中的
<database>.Store
下删除该表,然后使用Update Model from Database..
命令检索该表。
关于sql - 无法将 “X”上的 “Y”属性设置为 'null'值。您必须将此属性设置为 'Int32'类型的非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13420037/