Example #1
0
        public override void PreInitialize()
        {
            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <MetroStationDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        MetroStationDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        MetroStationDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });

                Configuration.Modules.AbpEfCore().AddDbContext <AuditLogDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        AuditLogDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        AuditLogDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });
            }
        }
        public MetroStationDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <MetroStationDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            MetroStationDbContextConfigurer.Configure(builder, configuration.GetConnectionString(MetroStationConsts.ConnectionStringName));

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