My project is becoming quite large and my fluent api extensive.
Is there a way I can separate my fluent api concerns to multiple files and reference them in my OnModelCreating?
My project is becoming quite large and my fluent api extensive.
Is there a way I can separate my fluent api concerns to multiple files and reference them in my OnModelCreating?
The link to the solution was not very specific, so here it is spelled out:
[Context file]
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new Configurations.DataContext.EmployeeConfiguration(modelBuilder));
....
}
[Configuration file]
public class EmployeeConfiguration : EntityTypeConfiguration<Employee>
{
public EmployeeConfiguration(DbModelBuilder modelBuilder)
{ ... }
....
}
The point to be mindful of is: When creating the constructor in the configuration, include the modelBuilder parameter.
When adding the configuration in OnModelcreating, be sure to pass along the modelBuilder parameter.