[英]How to undo Entity Framework Update-Database in .NET Core
In the standard .NET version of entity framework, you could undo the last database update using. 在标准.NET版本的实体框架中,您可以使用撤消上次数据库更新。
Update-Database -TargetMigration "NameOfPreviousMigration"
If you try this on Entity Framework for .NET Core (EntityFrameworkCore), you get the following error: 如果您在Entity Framework for .NET Core(EntityFrameworkCore)上尝试此操作,则会收到以下错误:
Update-Database : A parameter cannot be found that matches parameter name 'TargetMigration'. Update-Database:找不到与参数名称“TargetMigration”匹配的参数。 At line:1 char:17 + Update-database -TargetMigration "NameOfPreviousMigration" + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Update-Database], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Update-Database 在行: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? 如何在.NET Core中还原数据库?
To do this in EntityFrameworkCore, you don't use the TargetMigration parameter. 要在EntityFrameworkCore中执行此操作,请不要使用TargetMigration参数。 Just name the migration you wish to revert to. 只需命名要恢复的迁移。
eg 例如
Update-Database NameOfPreviousMigration
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.