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.
Trying to set a non-null string to type 'System.Int32'
Just for anyone else having issues with this. Set a breakpoint in DatabaseContext
and make sure it's connecting to the correct database. Mine was being overwritten from a web.config file I forgot about.
The 'XXX' property on 'XXX' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.DateTime'
DateTime is a reference type. You need to use Nullable DateTime in your class.
DateTime? ResolveDate = null;
or
Nullable<DateTime> ResolveDate ;
InvalidOperationException You must set this property to a non-null value of type string
I had a similar issue but for byte to bool
I edited my entity
public byte XX { get; set; }
Then edited my Model to have
public bool XX { get; set; }
used auto mapper to map them together and it fixed the issue i was having, try this with editing your Model to a string and map it accordingly.
i am using code first for my existing databases, but it may work for db first
Related Topics
Iterate Through a List of Strings in SQL Server
Pagination with The Stored Procedure
Hiveql - How to Find The Column Value Is Numeric or Not Using Any Udf
SQL Query for Courses Enrolment on Moodle
Get the List of Stored Procedures Created And/Or Modified on a Particular Date
How to Get the Employees with Their Managers
Duplicate Postgresql Schema Including Sequences
Activerecord Query, Order by Association, Last of Has_Many
How to Concat_Ws Multiple Fields and Remove Duplicate Separators for Empty Slots
Mod' Is Not a Recognized Built-In Function Name
How to Use T-SQL Full-Text Search to Get Results Like Google
Sql Query to Sum Fields from Different Tables
How to Count All Rows with The Same Id with Count
Building a Table Dependency Graph with a Recursive Query
Ruby on Rails Where Query with Nesting Relations