Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Bigint Unsigned cause error when mapping to ulong/UInt64 (1 reply)

$
0
0
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?

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>