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