简体   繁体   English

如何在.NET Core中撤消Entity Framework Update-Database

[英]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.

相关问题 实体框架核心 - “更新数据库”不起作用 - Entity Framework Core - 'Update-Database' not working Entity Framework Core 不在更新数据库上创建数据库 - Entity Framework Core not creating database on update-database 实体框架核心更新-数据库特定迁移 - Entity framework Core Update-database specific migration 在 Entity Framework Core 中使用 Update-Database 添加新列 - Adding new column using Update-Database in Entity Framework Core Update-Database 命令在 ASP.Net Core / Entity Framework Core 中不起作用,因为数据库中的对象已经存在 - Update-Database command is not working in ASP.Net Core / Entity Framework Core because object in database already exists 实体框架6中“更新数据库”之后发生错误 - Error after 'update-database' in Entity Framework 6 带有-ConnectionString的实体框架更新数据库 - Entity Framework Update-Database with -ConnectionString 无法在.NET Core中使用EF更新数据库 - Cannot Update-Database with EF in .NET Core 实体框架核心更新-数据库特定的迁移没有权限错误 - Entity Framework Core Update-database specific migration gives no permission error 实体框架核心,更新数据库不考虑属性 - Entity framework core, update-database don't take account of attributes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM