So I tried to use automatic migrations with my new MVC 4 Project but somehow it isn\'t working. I followed this blog post step by step.
I\'ve added the changes to th
What it looks like happened here is that you enabled migrations, then ran the application. By running the application before using the UpdateDatabase command, EntityFramework would have created and populated the database but since when you enabled migrations the database didn't exist, it didn't create the InitialCreate migration. Migrations still thinks that you have an empty database and wants to create all of the objects in your model
What you can try is to either re-enable migrations which will generate an InitialCreate migration that reflects the current state of the database. In this case I would save the changes you made to the seed method than run "Enable-Migrations -Force", this should recreate the migration and generate an IntialCreate migration. You can then repopulate your seed method and run the UpdateDatabase command.
I had same and sorted in different way. Went to my local db deleted the UserProfile and other tables having foreign key constraints webpages_Membership,webpages_OAuthMembership,webpages_Roles,webpages_UsersInRoles tables. All these will recreate when you run update-database -verbose.
update-database -verbose
doesn't work because your model has been changed after your data table already existed.
First, make sure there are no changes to the UserProfile class. Then, run:
Add-Migration InitialMigrations -IgnoreChanges
This should generate a blank "InitialMigration" file. Now, add any desired changes to the UserProfile class. Once changes are added, run the update command again:
update-database -verbose
Now the automatic migration will be applied and the table will be altered with your changes.