Ok, so in the essence of framework 6, I would have generated a database of keys and properties in one expression:
modelBuilder.Entity<Function>()
.HasKey(x => x.Id)
.Property(x => x.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
In the core of entity (7), this does not work:
modelBuilder.Entity<Function>()
.HasKey(x => x.Id)
.Property(x => x.Id)
.ValueGeneratedNever();
Error: "KeyBuilder" does not contain a definition for "Property" and no extension method "Property" that takes the first argument of type "KeyBuilder":
Should it be two separate operators, as shown below, or is there a way to have it in one, as you could in EF6?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Function>()
.HasKey(x => x.Id);
modelBuilder.Entity<Function>()
.Property(x => x.Id)
.ValueGeneratedNever();
}
source
share