private void PrepareDatabaseMigrations(DbMigrator migrator, EFMigrationDetails migrationDetails) { var databaseMigrations = migrator.GetDatabaseMigrations().Select(v => new SelectListItem { Text = EFMigrationDetails.GetDisplayName(v), Value = v }).ToList(); SelectListItem disabledItem = new SelectListItem { Text = "--------------------------------------", Value = "", Disabled = true, }; if (databaseMigrations.Any()) { databaseMigrations = databaseMigrations.Skip(1).ToList(); if (databaseMigrations.Any()) { databaseMigrations.Add(disabledItem); } databaseMigrations.Add(new SelectListItem { Text = "<<Remove All Migrations>>", Value = "0" }); } migrationDetails.Migrations = new SelectList(databaseMigrations, "Value", "Text", databaseMigrations.FirstOrDefault(m => !m.Disabled), new List <string> { disabledItem.Value }); migrationDetails.TargetMigration = databaseMigrations.Where(m => !m.Disabled).Select(si => si.Value).FirstOrDefault(); }
private void PreparePendingMigrations(DbMigrator migrator, EFMigrationDetails migrationDetails) { var migrations = migrator.GetPendingMigrations().ToList(); var pendingMigrations = migrations.Select(v => new SelectListItem { Text = EFMigrationDetails.GetDisplayName(v, string.Compare(migrations.LastOrDefault(), v, true) == 0), Value = v }); migrationDetails.Migrations = new SelectList(pendingMigrations, "Value", "Text", pendingMigrations.LastOrDefault()); migrationDetails.TargetMigration = pendingMigrations.Select(si => si.Value).LastOrDefault(); }