Example #1
0
        public BlogDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <BlogDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            BlogDbContextConfigurer.Configure(builder, configuration.GetConnectionString(BlogConsts.ConnectionStringName));

            return(new BlogDbContext(builder.Options));
        }
Example #2
0
 public override void PreInitialize()
 {
     if (!SkipDbContextRegistration)
     {
         Configuration.Modules.AbpEfCore().AddDbContext <BlogDbContext>(options =>
         {
             if (options.ExistingConnection != null)
             {
                 BlogDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
             }
             else
             {
                 BlogDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
             }
         });
     }
 }