Donate

The specified cast from a materialized 'System.Int16' type to a nullable 'System.Int32' type is not valid In C#

Based from the issue, the fix is to check the database field against the view model class. In my case, the database field is smallint (nullable).
So, the fix is to change the model code from int datatype:
public int? StockOnHand { get; set; }
To Int16 datatype:
public Int16? UnitsInStock { get; set; }  
:-)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input