コード例 #1
0
        public SalesDbContext CreateDbContext(string[] args)
        {
            var builder         = new DbContextOptionsBuilder <SalesDbContext>();
            var configuration   = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT"));
            var databaseOptoins = configuration.GetSection(nameof(DatabaseOptions)).Get <DatabaseOptions>();


            SalesDbContextConfigurer.Configure(
                builder,
                configuration.GetConnectionString(SalesConsts.ConnectionStringName)
                );

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