I have a bigint unsigned on my database. This should be mapped to ulong/UInt64 to retain value. I've made a model with ulong property. The problem is, when I simply call context.DbSet<T>.ToList(), it throws this exception:
An unhandled exception has occurred: Unable to cast object of type 'System.Int64' to type 'System.UInt64'.
System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.UInt64'.
at System.Data.Common.DbDataReader.GetFieldValue[T](Int32 ordinal)
at lambda_method(Closure , DbDataReader )
This is my entity model:
public class BaseEntity
{
[Key]
public ulong Id { get; set; }
}
Any idea why a bigint unsigned was read using int64 instead of uint64?
An unhandled exception has occurred: Unable to cast object of type 'System.Int64' to type 'System.UInt64'.
System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.UInt64'.
at System.Data.Common.DbDataReader.GetFieldValue[T](Int32 ordinal)
at lambda_method(Closure , DbDataReader )
This is my entity model:
public class BaseEntity
{
[Key]
public ulong Id { get; set; }
}
Any idea why a bigint unsigned was read using int64 instead of uint64?