[Feature] Generate IEntityTypeConfiguration<T> Mappers
See original GitHub issueCurrently all the mapping of the EntityTypes are generated in the function:
protected override void OnModelCreating(ModelBuilder modelBuilder)
. This can become pretty large…
I suggest we create scaffold a IEntityTypeConfiguration
file for each entity and use these in the
OnModelCreating
function.
For example: Customer.cs
CustomerConfiguration.cs
internal class CustomerConfiguration : IEntityTypeConfiguration<Customer>
{
public void Configure(EntityTypeBuilder<Customer> builder)
{
builder.HasKey(c => c.AlternateKey);
builder.Property(c => c.Name).HasMaxLength(200);
// ...
}
}
DbContext
// OnModelCreating
builder.ApplyConfiguration(new CustomerConfiguration());
Optional:
- Choose a template name suffix
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Creating and Configuring a Model - EF Core
This model is built using a set of conventions - heuristics that look for common patterns. The model can then be customized using...
Read more >EF Core Mapping EntityTypeConfiguration
Try the new dependency injection tools? Make an IEntityMapperStrategy interface with a void MapEntity(ModelBuilder, Type) signature and bool ...
Read more >A Cleaner Way To Do Entity Configuration With EF Core
It works like this. Create a class called {EntityName}Configuration and inherit from IEntityTypeConfiguration<Entity>. public ...
Read more >Customizing EF Core 2.0+ Entity/Table Mapping with ...
Let's say you want to make a customization to one of your EF Core 2.0 properties and how it maps to your underlying...
Read more >Implementing Missing Features in Entity Framework Core
My implementation finds mapping classes in the same assembly as the context ... public interface IEntityTypeConfiguration<T> where T : class
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The project is open source and accepts PRs
Will implement using https://github.com/lauxjpn/DbContextOnModelCreatingSplitter - initially just a checkbox to enable this!