How to recreate my EF CodeFirst Table?

code-first entity-framework

Question

I created a Code First class

A database was created in Sql automatically.

I deleted the tables :(

I have migrations enabled:

AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
Database.SetInitializer(new DropCreateDatabaseAlways<SurveyContext>());

Yet upon

update-database -force

Cannot find the object "dbo.CustomerResponses" because it does not exist or you do not have permissions.

Please help.

1
10
1/30/2013 9:05:28 PM

Popular Answer

In system tables there is a table called

__MigrationHistory

...I deleted it.

In Package manager console ran command "update-database" Problem fixed!

More info:

http://blog.oneunicorn.com/2012/02/27/code-first-migrations-making-__migrationhistory-not-a-system-table/

9
1/30/2013 9:04:34 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow