Mar*_*uta 25 sql entity-framework visual-studio-2010
当我运行我的应用程序并单击特定按钮时,我收到错误:
"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'."
Run Code Online (Sandbox Code Playgroud)
好吧,我转到我的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.
Run Code Online (Sandbox Code Playgroud)
我听说从.edmx文件中删除该表然后重新添加它是一种可能性,但从未这样做过,并且不明白其含义足以令人感到舒服.
我听说它可能在视图中,可能在存储过程中......
也听说这是一个bug.
有没有人遇到过这个并发现了一个"全面"修复或某种路线图,在哪里寻找这个错误?
谢谢!
Bob*_*ob. 27
"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'."
Run Code Online (Sandbox Code Playgroud)
在您的EDMX中,如果您在Y表下并单击X列,请右键单击,单击"属性",向下滚动Nullable
并从中更改False
为True
.
如果您收到"映射片段"错误,则必须从EDMX中删除该表并重新添加它,因为在模型浏览器中它存储表属性以及刷新它的唯一方法(我知道)是从模型浏览器中删除表,<database>.Store
然后使用Update Model from Database..
命令检索它.
小智 21
我只是将数据类型替换int
为int32?
public Int32 Field{ get; set; }
Run Code Online (Sandbox Code Playgroud)
至
public Int32? Field{ get; set; }
Run Code Online (Sandbox Code Playgroud)
问题解决了
归档时间: |
|
查看次数: |
54904 次 |
最近记录: |