I am using Entity Framework code-first migrations. And I created a migration to change the name of a table in my database:
public partial class ChangeNameOfCodePerformanceAnchorTable : DbMigration
{
public override void Up()
{
RenameTable(name: "dbo.Code_PerformanceAnchor", newName: "CodePerformanceAnchor");
}
public override void Down()
{
RenameTable(name: "dbo.CodePerformanceAnchors", newName: "Code_PerformanceAnchor");
}
}
Now, when I create the controller for that table.. on the Index action I have this:
public ActionResult Index()
{
return View(db.CodePerformanceAnchor.Include(c => c.CodePhase).ToList());
}
When I run the application to get to that specific index page, I get this error:
Invalid object name 'dbo.CodePerformanceAnchors'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.CodePerformanceAnchors'.
The only thing in my application that is called CodePerformanceAnchors
is the controller. The model is CodePerformanceAnchor
.
public virtual DbSet<CodePerformanceAnchor> CodePerformanceAnchor { get; set; }
Any help on resolving this error would be greatly appreciated.