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'
"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'."
In your EDMX, if you go under your Y table and click on X column, right-click, click on Properties, scroll down to Nullable
and change from False
to True
.
If you get a "mapping fragment" error, you'll have to delete the table from the EDMX and re-add it, because in the Model Browser it stores the table properties and the only way to refresh that (that I know of) is to delete the table from the Model Browser under <database>.Store
then retrieving it using Update Model from Database..
command.
I just replace data type int
to int32?
public Int32 Field{ get; set; }
to
public Int32? Field{ get; set; }
and the problem is solved
My problem was that my Model database was out of sync with the actual (dev) database. So the EDMX thought it was smallint
but the actual column was int. I updated the model database to int
and the EDMX to Int32
and now it works.