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

            BlogServiceDbContextConfigurer.Configure(builder, configuration.GetConnectionString(BlogServiceConsts.ConnectionStringName));

            return(new BlogServiceDbContext(builder.Options));
        }
Exemplo n.º 2
0
        public override void PreInitialize()
        {
            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <BlogServiceDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        BlogServiceDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        IHostingEnvironment env = IocManager.Resolve <IHostingEnvironment>();
                        var connString          = env.GetAppConfiguration().GetConnectionString(BlogServiceConsts.ConnectionStringName);

                        BlogServiceDbContextConfigurer.Configure(options.DbContextOptions, connString);
                    }
                });
            }
        }