Exemplo n.º 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));
        }
Exemplo n.º 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);
         }
     });
 }
Exemplo n.º 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);
         }
     });
 }