4
votes

I am writing this for an identity column in Entity Framework Core 2 with SQL Server, and getting this error

Propertybuilder does not contain a definition for UseSqlServerIdentityColumn

How do I fix this?

enter image description here

1

1 Answers

3
votes

In EF Core 2.0, the syntax has changed a bit. This method should now work:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{    
  modelBuilder.Entity<MyEntity>(b =>
  {
    b.HasKey(e => e.Identifier);
    b.Property(e => e.Identifier).ValueGeneratedOnAdd();
  }
}

My guess is this was done so that the same method could be used across storage providers (not just SQL Server).

Largely copied from similar answer here: https://stackoverflow.com/a/35847279/2343739