开发者

Entity Framework 4.0 - Upgrading a database from an existing model

I'm doing a web app using EF 4.0, and taking the "model first" approach - so I define all my entities, generate a DDL and create a database structure based the model.

Now, every time something changes in the model, I regenerate the DDL and the database structure is recreated from scratch - tables are dropped and recreated. In this process, I lose all configuration data that was already. This is fine for now, but going forward, once the app goes to production, how will I be able to upgrade the database if I decide to change something?

To simplify, (ho开发者_运维百科w) can I upgrade the database from the model and keep all the data?

Thanks!


You need another workflow or T4 templated for DB generation. It is already available in Entity Designer Database Generation Power pack extension for Visual Studio 2010. The only problem is that these workflows are using database tools from Visual Studio which are only available in Premium and Ultimate edition.

If you don't have VS 2010 Premium or Ultimate you must deploy new DB to test environment first and write diff script by yourselves or buy some diff script generator - I recommend DB tools from Red Gate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜