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 definit
In EF Core 2.0, the syntax has changed a bit. This method should now work:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(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