public FMSDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <FMSDbContext>(); string env = null; env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development"; Console.WriteLine($"Environment : {env}"); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), env); Console.WriteLine($"Connection : {configuration.GetConnectionString(FMSConsts.ConnectionStringName)}"); FMSDbContextConfigurer.Configure(builder, configuration.GetConnectionString(FMSConsts.ConnectionStringName)); return(new FMSDbContext(builder.Options)); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <FMSDbContext>(options => { if (options.ExistingConnection != null) { FMSDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { FMSDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); } }