Ok, so I am using an entity infrastructure with a kernel and a clean core and first code porting. This is not a problem as such, I just wondered if anyone had found a better way to do this.
I currently have many object type configurations such as
public class ExampleEntityConfiguration : IEntityTypeConfiguration<ExampleEntity>
{
public void Configure(EntityTypeBuilder<ExampleEntity> builder)
{
builder.Property(p => p.Id).ValueGeneratedNever();
// more options here
}
}
and I will register them in my dbcontext so
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfiguration(new ExampleEntityConfiguration());
// lot more configurations here
}
Has anyone come across or knew a way to register all interfaces IEntityTypeConfiguration
?
It just looks like a lot of repeating code that can be solved by getting a list of configurations, going through them and applying them in context. I just don’t know where to start by getting a list of classes IEntityTypeConfiguration
that exist in a particular namespace.
/ .