update database命令不起作用

ivqmmu1c  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(254)

我用ef6创建了一个数据库。现在我想重命名一个表和一些列。迁移的代码如下

public partial class AdjustJunctionTable : DbMigration
{
    public override void Up()
    {
        RenameTable(name: "dbo.SoftwareSoftwares", newName: "Dependency");
        RenameColumn(table: "dbo.Dependency", name: "Software_StandardPartNumber", newName: "DependentStandardPartNumber");
        RenameColumn(table: "dbo.Dependency", name: "Software_Version", newName: "DependentVersion");
        RenameColumn(table: "dbo.Dependency", name: "Software_StandardPartNumber1", newName: "DependencyStandardPartNumber");
        RenameColumn(table: "dbo.Dependency", name: "Software_Version1", newName: "DependencyVersion");
        RenameIndex(table: "dbo.Dependency", name: "IX_Software_StandardPartNumber_Software_Version", newName: "IX_DependentStandardPartNumber_DependentVersion");
        RenameIndex(table: "dbo.Dependency", name: "IX_Software_StandardPartNumber1_Software_Version1", newName: "IX_DependencyStandardPartNumber_DependencyVersion");
    }

    public override void Down()
    {
        RenameIndex(table: "dbo.Dependency", name: "IX_DependencyStandardPartNumber_DependencyVersion", newName: "IX_Software_StandardPartNumber1_Software_Version1");
        RenameIndex(table: "dbo.Dependency", name: "IX_DependentStandardPartNumber_DependentVersion", newName: "IX_Software_StandardPartNumber_Software_Version");
        RenameColumn(table: "dbo.Dependency", name: "DependencyVersion", newName: "Software_Version1");
        RenameColumn(table: "dbo.Dependency", name: "DependencyStandardPartNumber", newName: "Software_StandardPartNumber1");
        RenameColumn(table: "dbo.Dependency", name: "DependentVersion", newName: "Software_Version");
        RenameColumn(table: "dbo.Dependency", name: "DependentStandardPartNumber", newName: "Software_StandardPartNumber");
        RenameTable(name: "dbo.Dependency", newName: "SoftwareSoftwares");
    }
}

当然,我使用 Add-Migration 命令。但是我想用 Update-Database 命令数据库中没有任何更改。使用 -verbose 参数仅显示其正在尝试更新 MigrationHistory 表,但在update命令之后,该表也不会更新。
包管理器控制台告诉我,它正在应用迁移,并警告:
注意:更改对象名称的任何部分都可能破坏脚本和存储过程。
那么如何才能成功地运行迁移呢?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题