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