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

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

在 Entity Framework 的标准 .NET 版本中,您可以 undo最后一次数据库更新使用。

Update-Database -TargetMigration "NameOfPreviousMigration"

如果您在 .NET Core Entity Framework (EntityFrameworkCore) 上尝试此操作,您会收到以下错误:

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

如何在 .NET Core 中还原数据库?

最佳答案

要在 EntityFrameworkCore 中执行此操作,您不使用 TargetMigration 参数。只需命名您希望恢复到的迁移即可。

例如

Update-Database NameOfPreviousMigration

关于c# - 如何在 .NET Core 中撤消 Entity Framework Update-Database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40306038/

相关文章:

c# - 如何使用 Xamarin.Forms 中的转换器将文本转换为颜色?

asp.net-core - 具有 Asp.net Core 依赖注入(inject)的 Service Fabric 有状态服务

c# - 在 Dynamic Linq 中合并

c# - 在 UWP Xaml 中创建和填充 NxN 网格

c# - 将 DbSet 转换为 DbSet<T>,其中 T 是 dbset 元素类型的接口(interface)

c# - 为什么新创建的 EF 实体在尝试保存时抛出 ID is null 异常?

entity-framework - Entity Framework Power Tools Beta 3 在尝试生成 View 时抛出异常 "sequence contains no matching element"

c# - asp.net 核心 Razor 页面 'loading indicator'

c# - 模型状态错误 : The value 'null' is not valid for nullable field

c# - 在 xamarin 上构建资源目录错误