In EF 6 we could directly pass EntityTypeConfiguration to model builder to build maps and keep our configuration class separate from context without being too verbose in code.
Have they removed those maps in EF core. Is there a way to add configuration without doing it in model builder for every class?
EntityFrameworkCore2.0 has a IEntityTypeConfiguration<TEntity>
which can be used as:
class ApplicationUserMap : IEntityTypeConfiguration<ApplicationUser>
{
public void Configure(EntityTypeBuilder<Customer> builder)
{
builder.ToTable("user", "identity");
builder.Property(p => p.Id)
.HasColumnName("id");
...
}
}
...
// OnModelCreating
modelBuilder.ApplyConfiguration(new ApplicationUserMap());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With