EF DatabaseGeneratedOption.Identity attribute does not work for ulong type

[Table( "User" )]
public class User
    [DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )]
    public ulong Id { get; set; }
    // other columns


For this code, I am getting an exception:

System.Data.Entity.Edm.EdmEntityType :: EntityType "User" has no key defined. Define a key for this EntityType.

But changing the id type to int, everything works fine.

    [DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )]
    public int Id { get; set; }


How do I get the ability to auto-create tables with an identifier having a capacity of type ulong? (obviously using ef code)


source to share

1 answer

Considering the numeric types of sql servers are:

bigint, numeric, bit, smallint, decimal, smallmoney, int, tinyint, money

it becomes clear that the CLR UInt64

( ulong

) type does not map to any of these types.



All Articles