Bigint Unsigned cause error when mapping to ulong/UInt64
Posted by: Firstiar Noorwinanto
Date: October 12, 2016 03:58AM

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?

Options: ReplyQuote


Subject
Written By
Posted
Bigint Unsigned cause error when mapping to ulong/UInt64
October 12, 2016 03:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.