public AbpProjectNameDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <AbpProjectNameDbContext>(); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); AbpProjectNameDbContextConfigurer.Configure(builder, configuration.GetConnectionString(AbpProjectNameConsts.ConnectionStringName)); return(new AbpProjectNameDbContext(builder.Options)); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <AbpProjectNameDbContext>(configuration => { AbpProjectNameDbContextConfigurer.Configure(configuration.DbContextOptions, configuration.ConnectionString); }); } }
public AbpProjectNameDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <AbpProjectNameDbContext>(); /* * You can provide an environmentName parameter to the AppConfigurations.Get method. * In this case, AppConfigurations will try to read appsettings.{environmentName}.json. * Use Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") method or from string[] args to get environment if necessary. * https://docs.microsoft.com/en-us/ef/core/cli/dbcontext-creation?tabs=dotnet-core-cli#args */ var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); AbpProjectNameDbContextConfigurer.Configure(builder, configuration.GetConnectionString(AbpProjectNameConsts.ConnectionStringName)); return(new AbpProjectNameDbContext(builder.Options)); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <AbpProjectNameDbContext>(options => { if (options.ExistingConnection != null) { AbpProjectNameDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { AbpProjectNameDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); } }