public QksPluginDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <QksPluginDbContext>(); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); //可以在这里切换数据库 QksPluginDbContextConfigurer.Configure(builder, configuration.GetConnectionString(QksConsts.ConnectionStringName)); return(new QksPluginDbContext(builder.Options)); }
public static void InitDbContext(IAbpStartupConfiguration configuration) { configuration.Modules.AbpEfCore().AddDbContext <QksPluginDbContext>(options => { if (options.ExistingConnection != null) { QksPluginDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { QksPluginDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); }
public override void PreInitialize() { Configuration.Modules.AbpEfCore().AddDbContext <QksPluginDbContext>(options => { if (options.ExistingConnection != null) { QksPluginDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { QksPluginDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); }