'Update database schema without dropping data?
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
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
