public SalesDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <SalesDbContext>(); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT")); var databaseOptoins = configuration.GetSection(nameof(DatabaseOptions)).Get <DatabaseOptions>(); SalesDbContextConfigurer.Configure( builder, configuration.GetConnectionString(SalesConsts.ConnectionStringName) ); return(new SalesDbContext(databaseOptoins, builder.Options)); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <SalesDbContext>(options => { if (options.ExistingConnection != null) { SalesDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { SalesDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); } }