How to undo Entity Framework Update-Database in .NET Core

.net-core asp.net-core c# entity-framework entity-framework-core

Question

In the standard .NET version of entity framework, you could undo the last database update using.

Update-Database -TargetMigration "NameOfPreviousMigration"

If you try this on Entity Framework for .NET Core (EntityFrameworkCore), you get the following error:

Update-Database : A parameter cannot be found that matches parameter name 'TargetMigration'. At line:1 char:17 + Update-database -TargetMigration "NameOfPreviousMigration" + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Update-Database], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Update-Database

How can I revert the database in .NET Core?

1
4
5/23/2017 12:13:50 PM

Accepted Answer

To do this in EntityFrameworkCore, you don't use the TargetMigration parameter. Just name the migration you wish to revert to.

e.g.

Update-Database NameOfPreviousMigration
13
10/28/2016 1:22:20 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow