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

            ContactsDbContextConfigurer.Configure(builder, configuration.GetConnectionString(ContactsConsts.ConnectionStringName));

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