Exemple #1
0
        public override void PreInitialize()
        {
            Configuration.ReplaceService <IConnectionStringResolver, MyConnectionStringResolver>();

            Configuration.Modules.AbpEfCore().AddDbContext <MultipleDataBaseDbContext>(options =>
            {
                if (options.ExistingConnection != null)
                {
                    DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                }
                else
                {
                    DbContextOptionsConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                }
            });

            Configuration.Modules.AbpEfCore().AddDbContext <SecondDbContext>(options =>
            {
                if (options.ExistingConnection != null)
                {
                    SecondDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                }
                else
                {
                    SecondDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                }
            });
        }
Exemple #2
0
        public MultipleDataBaseDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <MultipleDataBaseDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

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

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