Home

Help with getting DBContext setup for LinqPad7

edited March 2023

I'm currently working on a rather large data model that uses .NET 7 and EF Core 7. We've broken up the OnModelCreating into sub-modules that get wired up through DI. My DbContext is setup as follows:

 public class FooDbContext : DbContext
 {
    private readonly IEnumerable<IModelConfigurator> modelConfigurators;

    public FooDbContext(
        DbContextOptions options,
        IEnumerable<IModelConfigurator> modelConfigurators)
        : base(options)
    {
        this.modelConfigurators = modelConfigurators;
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        foreach (var configurator in modelConfigurators)
        {
            configurator.Configure(modelBuilder);
        }
    }
}

I can change the constructor to pass in a connection string but what about the DI stuff?

Sign In or Register to comment.