예제 #1
0
        public DbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <DbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            DbContextOptionsConfigurer.Configure(
                builder,
                configuration.GetConnectionString(AppConsts.ConnectionStringName)
                );

            return(new DbContext(builder.Options));
        }
예제 #2
0
 public override void PreInitialize()
 {
     if (!SkipDbContextRegistration)
     {
         Configuration.Modules.AbpEfCore().AddDbContext <DbContext>(options =>
         {
             if (options.ExistingConnection != null)
             {
                 DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
             }
             else
             {
                 DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
             }
         });
     }
 }