daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected override void Seed(LightCms.Domain.EF.LightCmsDBContext context)
  2. {
  3.     //  This method will be called after migrating to the latest version.
  4.  
  5.     //  You can use the DbSet<T>.AddOrUpdate() helper extension method
  6.     //  to avoid creating duplicate seed data.
  7. }
  8.    
  9. protected override void OnModelCreating(DbModelBuilder modelBuilder)
  10. {
  11.     base.OnModelCreating(modelBuilder);
  12.     //modelBuilder.Entity<HistoryRow>().ToTable("tbl_migration_history");
  13.     modelBuilder.Entity<HistoryRow>().ToTable(tableName: "tbl_migration_history");
  14.     modelBuilder.Entity<HistoryRow>().HasKey(
  15.         h => new
  16.         {
  17.             h.MigrationId,
  18.             h.ContextKey
  19.         });
  20.     modelBuilder.Entity<HistoryRow>().Property(h => h.MigrationId).HasColumnName("migration_id").HasMaxLength(150).IsRequired();
  21.     modelBuilder.Entity<HistoryRow>().Property(h => h.ContextKey).HasColumnName("context_key").HasMaxLength(300).IsRequired();
  22.     modelBuilder.Entity<HistoryRow>().Property(h => h.Model).HasColumnName("model").IsRequired().IsMaxLength();
  23.     modelBuilder.Entity<HistoryRow>().Property(h => h.ProductVersion).HasColumnName("product_version").HasMaxLength(32).IsRequired();
  24. }
  25.    
  26. public static void InitializeMigrations()
  27.     {
  28.         //System.Data.Entity.Database.SetInitializer(new System.Data.Entity.MigrateDatabaseToLatestVersion<LightCmsDBContext, CmsDbMigrationConfiguration>());
  29.         var configuration = new CmsDbMigrationConfiguration();
  30.         //configuration.SetHistoryContextFactory(SqlProviderServices.ProviderInvariantName, (c, e) => new CmsMigrationHistoryContext(c, e));
  31.         var migrator = new CmsDbMigrator(configuration);
  32.         var history = migrator.GetDatabaseMigrations();
  33.         var local = migrator.GetLocalMigrations();
  34.         if (migrator.GetPendingMigrations().Any())
  35.         {
  36.             migrator.Update();
  37.         }
  38.     }
  39.    
  40. protected void Application_Start(object sender, EventArgs e)
  41.     {
  42.         // The model backing the 'LightCmsDBContext' context has changed since the database was created.
  43.         // Consider using Code First Migrations to update the database
  44.         //Database.SetInitializer<LightCmsDBContext>(null);
  45.         MvcBootstrapper.InitializeMigrations();
  46.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top