Identity value generation can only be used with signed integer properties after upgrade to EF Core 1.1

asp.net-core asp.net-core-1.0 entity-framework-core

Question

When I updated "Microsoft.EntityFrameworkCore.Tools.DotNet" to version "1.1.0-preview4", entity framework has stopped to generate migrations.

Error:

dotnet : System.ArgumentException: Identity value generation cannot be used      
for the property 'UID' on entity type 'SomeEntity' because the property type is   
'Guid'. Identity value generation can only be used with signed integer properties.
1
2
11/29/2016 5:55:16 PM

Popular Answer

Solution is get rid of attribute [DatabaseGenerated(DatabaseGeneratedOption.Identity)]

[Key]
// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] <-- remove this
public Guid UID { get; set; }

and update model builder

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    // add this:
    modelBuilder.Entity<SomeEntity>().Property(p => p.UID).ValueGeneratedOnAdd();
}
3
11/29/2016 3:49:43 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow