Bir çift varlığın adını ve gezinti özelliklerini yeniden adlandırdım ve EF 5'te yeni bir Migration oluşturdum. EF geçişlerinde yeniden adlandırmalarda olduğu gibi, varsayılan olarak nesneleri bırakacak ve yeniden oluşturacaktı. İstediğim bu değildi, bu yüzden geçiş dosyasını sıfırdan oluşturmak zorunda kaldım.
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");
}
Ben bunu yapmaya çalışıyorum Tüm Yeniden adlandırma olduğu dbo.ReportSectionsiçin dbo.ReportPagesve sonra dbo.ReportSectionGroupsiçin dbo.ReportSections. Sonra yabancı anahtar sütununu ' dbo.ReportPagesden' Group_Ide yeniden adlandırmam gerekiyor .Section_Id .
Tabloları birbirine bağlayan yabancı anahtarları ve dizinleri bırakıyorum, ardından tabloları ve yabancı anahtar sütununu yeniden adlandırıyorum, ardından dizinleri ve yabancı anahtarları yeniden ekliyorum. Bunun işe yarayacağını varsaydım ama bir SQL hatası alıyorum.
Msg 15248, Düzey 11, Durum 1, Prosedür sp_rename, Satır 215 Ya @objname parametresi belirsiz ya da talep edilen @objtype (SÜTUN) yanlış. Msg 4902, Düzey 16, Durum 1, Satır 10 "dbo.ReportSections" nesnesi bulunamıyor çünkü mevcut değil veya izinleriniz yok.
Burada neyin yanlış olduğunu anlamakta zorlanıyorum. Herhangi bir içgörü son derece yardımcı olacaktır.