Implementing Missing Features in Entity Framework Core
This is the seventh post in a series of posts about bringing the features that were present in Entity Framework pre-Core into EF Core. The others are: Part 1: Introduction, Find, Getting an Entity’s Id Programmatically, Reload, Local, Evict Part 2: Explicit Loading Part 3: Validations Part 4: Conventions Part 5: Getting the SQL for a Query Part 6: Lazy Loading This time I’m going to cover automatic entity configuration in mapping classes, that is, outside of the DbContext.OnModelCreating method. If you remember, Entity Framework Code First supported having classes inheriting from EntityTypeConfiguration in the same assembly as the context . public interface IEntityTypeConfiguration<T> where T : class { void Configure(EntityTypeBuilder<T> entityTypeBuilder); } The actual implementation goes like this: public static class EntityTypeConfigurationExtensions { private static readonly MethodInfo entityMethod = typeof(ModelBuilder).GetTypeInfo().GetMet...