Beispiel #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);
                }
            });
        }
        public SecondDbContext CreateDbContext(string[] args)
        {
            var builder = new DbContextOptionsBuilder <SecondDbContext>();

            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            SecondDbContextConfigurer.Configure(builder, configuration.GetConnectionString(MultipleDataBaseConsts.MySqlConnectionStringName));

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