public override void PreInitialize()
        {
            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <BiDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        BiDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        BiDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });

                // Configure second DbContext
                Configuration.Modules.AbpEfCore().AddDbContext <SecondDbContext.SecondDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        SecondDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        SecondDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });
            }
        }
예제 #2
0
        public BiDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <BiDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            BiDbContextConfigurer.Configure(builder, configuration.GetConnectionString(BiConsts.ConnectionStringName));

            return(new BiDbContext(builder.Options));
        }