Exemplo n.º 1
0
        public DemoDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <DemoDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            DemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString(DemoConsts.ConnectionStringName));

            return(new DemoDbContext(builder.Options));
        }
Exemplo n.º 2
0
 public override void PreInitialize()
 {
     Configuration.ReplaceService <IEfCoreTransactionStrategy, DbContextEfCoreTransactionStrategy>(DependencyLifeStyle.Transient);
     if (!SkipDbContextRegistration)
     {
         Configuration.Modules.AbpEfCore().AddDbContext <DemoDbContext>(options =>
         {
             if (options.ExistingConnection != null)
             {
                 DemoDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
             }
             else
             {
                 DemoDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
             }
         });
     }
 }