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