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