【问题标题】:Entity Framework migrations remove and update does not work实体框架迁移删除和更新不起作用
【发布时间】:2019-07-07 17:10:09
【问题描述】:

实体框架迁移添加工作完美,但迁移删除和更新不起作用。有什么问题?

dotnet --version
2.1.202

Entity Framework Core .NET 命令行工具 2.0.0-rtm-26452。

【问题讨论】:

  • 您能否提供更多上下文信息,例如您执行了哪些命令、结果是什么以及您希望的预期结果是什么。
  • 你能看看我下面的答案,让我知道它是否有效吗?

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


【解决方案1】:

您可以使用以下方法回滚到任何迁移:

Update-Database -TargetMigration:"MigrationName"

例如:

Update-Database -configuration YourProject.Migrations.Configuration -Verbose -
TargetMigration:"201903291233013_migration_001"

除此之外,您还可以从 MigrationHistory 表中删除 migration.cs 及其记录。希望这会有所帮助...

【讨论】:

    猜你喜欢
    • 2021-12-09
    • 1970-01-01
    • 2018-04-06
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    相关资源
    最近更新 更多