Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void Seed(LightCms.Domain.EF.LightCmsDBContext context)
- {
- // This method will be called after migrating to the latest version.
- // You can use the DbSet<T>.AddOrUpdate() helper extension method
- // to avoid creating duplicate seed data.
- }
- protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- //modelBuilder.Entity<HistoryRow>().ToTable("tbl_migration_history");
- modelBuilder.Entity<HistoryRow>().ToTable(tableName: "tbl_migration_history");
- modelBuilder.Entity<HistoryRow>().HasKey(
- h => new
- {
- h.MigrationId,
- h.ContextKey
- });
- modelBuilder.Entity<HistoryRow>().Property(h => h.MigrationId).HasColumnName("migration_id").HasMaxLength(150).IsRequired();
- modelBuilder.Entity<HistoryRow>().Property(h => h.ContextKey).HasColumnName("context_key").HasMaxLength(300).IsRequired();
- modelBuilder.Entity<HistoryRow>().Property(h => h.Model).HasColumnName("model").IsRequired().IsMaxLength();
- modelBuilder.Entity<HistoryRow>().Property(h => h.ProductVersion).HasColumnName("product_version").HasMaxLength(32).IsRequired();
- }
- public static void InitializeMigrations()
- {
- //System.Data.Entity.Database.SetInitializer(new System.Data.Entity.MigrateDatabaseToLatestVersion<LightCmsDBContext, CmsDbMigrationConfiguration>());
- var configuration = new CmsDbMigrationConfiguration();
- //configuration.SetHistoryContextFactory(SqlProviderServices.ProviderInvariantName, (c, e) => new CmsMigrationHistoryContext(c, e));
- var migrator = new CmsDbMigrator(configuration);
- var history = migrator.GetDatabaseMigrations();
- var local = migrator.GetLocalMigrations();
- if (migrator.GetPendingMigrations().Any())
- {
- migrator.Update();
- }
- }
- protected void Application_Start(object sender, EventArgs e)
- {
- // The model backing the 'LightCmsDBContext' context has changed since the database was created.
- // Consider using Code First Migrations to update the database
- //Database.SetInitializer<LightCmsDBContext>(null);
- MvcBootstrapper.InitializeMigrations();
- }
Add Comment
Please, Sign In to add comment