Reputation: 33691
I started using EF using database first and generating my diagram from the database.
Now I have switched and made many changes to my diagram and would like to update my database schema without data loss. However, generating database from the diagram seems to drop all the tables and recreate them.
I have found 'data migrations' for code first. Is there anything similar for model first, or any way I can maintain the data?
I am using VS 2012 with EF5
Upvotes: 11
Views: 13026
Reputation: 1970
Don't forget to search into SO site,
http://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87/
After installation, when you choose "Generate Database from Model..." it'll popup a new wizard and you can choose "Generate Migration T-SQL"
Another way is to use custom t4 to generate DbMigrationsConfiguration and DbContext from your model and you don't need to run Enable-Migration at all. Simply run Add-Migration and Update-Database in the Package Manager Console
http://blog.amusedia.com/2012/08/entity-framework-migration-with-model.html
Upvotes: 0