コード例 #1
0
        public NewDemoDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <NewDemoDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            NewDemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString(NewDemoConsts.ConnectionStringName));

            return(new NewDemoDbContext(builder.Options));
        }
コード例 #2
0
 public override void PreInitialize()
 {
     if (!SkipDbContextRegistration)
     {
         Configuration.Modules.AbpEfCore().AddDbContext <NewDemoDbContext>(options =>
         {
             if (options.ExistingConnection != null)
             {
                 NewDemoDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
             }
             else
             {
                 NewDemoDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
             }
         });
     }
 }