Q:

Deleted table in database; how to recreate it using Code First

After deleting table X in database, issued update-database command in PackageManagerConsole, and now I get the following error: "Cannot find the object "dbo.X" because it does not exist or you do not have permissions."
Considering this scenario, how to force CodeFirst to create the table from scratch?

A:

These are the work around steps that deals with this scenario:

delete table from db
delete all related stored procedures if any
create a new imitation entity/table class with a different/distinct name (ex. BlahBlah)
create any configs needed for the new entity inside OnModelCreating method
in the PackageConsoleManager, issue an add-migration command
open the migration file and replace all BlahBlah words with the old table name
Comment or delete the old table class
repeat 7 for old configs in OnModelCreating
rename the new table class with the old table class name
repeat 8 for the new table configs in OnModelCreating
in the PackageConsoleManager, issue an add-migration command again
if it creates a new migration, replace its content with the old migration created in step 6
in the PackageConsoleManager, issue update-database command

