Entity Framework 4.0 - Updating a Database from an Existing Model

I am building a web application using EF 4.0 and taking the “first model” approach, so I define all my entities, create a DDL and create a database structure based on the model.

Now, every time something changes in the model, I restore the DDL, and the database structure is recreated from scratch - the tables are discarded and recreated. In this process, I lost all the configuration data that was already there. This is fine at the moment, but moving forward as soon as the application goes into production, how can I update the database if I decide to change something?

To simplify, (how) can I update the database from the model and save all the data?

Thanks!

+4
source share
1 answer

You need another workflow or T4 template to generate the database. It is already available in the extension extension for creating the Entity Designer database for Visual Studio 2010. The only problem is that these workflows use the database tools from Visual Studio that are available only in Premium and Ultimate.

If you do not have VS 2010 Premium or Ultimate, you must first deploy a new database to test the environment and write a diff script yourself or buy a diff script generator - I recommend DB tools from Red Gate .

+4
source

Source: https://habr.com/ru/post/1341923/


All Articles