Wenn ich PM> Remove-Migration -context BloggingContext
in VS2015 mit einem ASP.NET Core-Projekt unter Verwendung von EF Core PM> Remove-Migration -context BloggingContext
ich folgende Fehlermeldung:
System.InvalidOperationException: The migration '20160703192724_MyFirstMigration' has already been applied to the database. Unapply it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration. at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.RemoveMigration(String projectDir, String rootNamespace, Boolean force)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.RemoveMigration(String contextType, Boolean force)
at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsRemoveCommand.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
The migration '20160703192724_MyFirstMigration' has already been applied to the database. Unapply it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration.
Wie kann ich es nicht anwenden? Ich verwende die neueste Version von ASP.NET Core 1.0, EF Core und VS2015 Update 3.
Verwenden:
CLI
> dotnet ef database update <previous-migration-name>
Package Manager-Konsole
PM> Update-Database <previous-migration-name>
Beispiel:
PM> Update-Database MyInitialMigration
Versuchen Sie dann, die letzte Migration zu entfernen.
Das Entfernen der Migration ohne Datenbankaktualisierung funktioniert nicht, da Sie Änderungen an der Datenbank vorgenommen haben.
Wenn Sie PMC verwenden, versuchen Sie Folgendes: PM> Datenbank aktualisieren 0 Dadurch wird die Datenbank gelöscht, und Sie können den Migrations-Snapshot von Ihrer Lösung entfernen