public MyCompanyDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <MyCompanyDbContext>(); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); MyCompanyDbContextConfigurer.Configure(builder, configuration.GetConnectionString(MyCompanyConsts.ConnectionStringName)); return(new MyCompanyDbContext(builder.Options)); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <MyCompanyDbContext>(options => { if (options.ExistingConnection != null) { MyCompanyDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { MyCompanyDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); } }