Entity Framework Migracje zmieniające nazwy tabel i kolumn

Zmieniłem nazwę na kilka podmiotów i ich właściwości nawigacyjne oraz wygenerowałem nową Migrację w EF 5. Jak zwykle przy zmianie nazw w migracjach EF, domyślnie zamierzał upuszczać obiekty i odtwarzać je. Nie to chciałem, więc musiałem zbudować plik migracji od podstaw.

    public override void Up()
    {
        DropForeignKey("dbo.ReportSectionGroups", "Report_Id", "dbo.Reports");
        DropForeignKey("dbo.ReportSections", "Group_Id", "dbo.ReportSectionGroups");
        DropForeignKey("dbo.Editables", "Section_Id", "dbo.ReportSections");
        DropIndex("dbo.ReportSectionGroups", new[] { "Report_Id" });
        DropIndex("dbo.ReportSections", new[] { "Group_Id" });
        DropIndex("dbo.Editables", new[] { "Section_Id" });

        RenameTable("dbo.ReportSections", "dbo.ReportPages");
        RenameTable("dbo.ReportSectionGroups", "dbo.ReportSections");
        RenameColumn("dbo.ReportPages", "Group_Id", "Section_Id");

        AddForeignKey("dbo.ReportSections", "Report_Id", "dbo.Reports", "Id");
        AddForeignKey("dbo.ReportPages", "Section_Id", "dbo.ReportSections", "Id");
        AddForeignKey("dbo.Editables", "Page_Id", "dbo.ReportPages", "Id");
        CreateIndex("dbo.ReportSections", "Report_Id");
        CreateIndex("dbo.ReportPages", "Section_Id");
        CreateIndex("dbo.Editables", "Page_Id");
    }

    public override void Down()
    {
        DropIndex("dbo.Editables", "Page_Id");
        DropIndex("dbo.ReportPages", "Section_Id");
        DropIndex("dbo.ReportSections", "Report_Id");
        DropForeignKey("dbo.Editables", "Page_Id", "dbo.ReportPages");
        DropForeignKey("dbo.ReportPages", "Section_Id", "dbo.ReportSections");
        DropForeignKey("dbo.ReportSections", "Report_Id", "dbo.Reports");

        RenameColumn("dbo.ReportPages", "Section_Id", "Group_Id");
        RenameTable("dbo.ReportSections", "dbo.ReportSectionGroups");
        RenameTable("dbo.ReportPages", "dbo.ReportSections");

        CreateIndex("dbo.Editables", "Section_Id");
        CreateIndex("dbo.ReportSections", "Group_Id");
        CreateIndex("dbo.ReportSectionGroups", "Report_Id");
        AddForeignKey("dbo.Editables", "Section_Id", "dbo.ReportSections", "Id");
        AddForeignKey("dbo.ReportSections", "Group_Id", "dbo.ReportSectionGroups", "Id");
        AddForeignKey("dbo.ReportSectionGroups", "Report_Id", "dbo.Reports", "Id");
    }

Wszystko, co próbuję zrobić, to zmienić nazwędbo.ReportSections dodbo.ReportPages i wtedydbo.ReportSectionGroups dodbo.ReportSections. Następnie muszę zmienić nazwę kolumny klucza obcego nadbo.ReportPages zGroup_Id doSection_Id.

Upuszczam klucze obce i indeksy łączące tabele razem, a następnie zmieniam nazwy tabel i kolumny klucza obcego, a następnie ponownie dodaję indeksy i klucze obce. Zakładałem, że to zadziała, ale otrzymuję błąd SQL.

Msg 15248, Level 11, State 1, Procedura sp_rename, Line 215 Albo parametr @objname jest niejednoznaczny, albo zastrzeżony @objtype (COLUMN) jest nieprawidłowy. Msg 4902, Level 16, State 1, Line 10 Nie można znaleźć obiektu „dbo.ReportSections”, ponieważ nie istnieje lub nie masz uprawnień.

Nie mam łatwego czasu, aby dowiedzieć się, co tu jest nie tak. Każdy wgląd byłby niezwykle pomocny.

questionAnswers(6)

yourAnswerToTheQuestion