예제 #1
0
        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));
        }
예제 #2
0
 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);
         }
     });
 }
예제 #3
0
 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);
         }
     });
 }