保持数据库内容在模式变迁模式、数据库、内容

2023-09-03 13:17:11 作者:抠脚美少女

使用新4.1 RC提供了code-第一的方针。

Using the code-first approach available in the new 4.1 RC.

有没有办法坚持存储在数据库中,当模式改变当前的数据?该数据库是由实体框架,模式的转变创造,和通常的数据库被删除并重新创建。

Is there any way to persist the current data stored in a database when the mode changes? The database is created by the entity framework, and usually the database is dropped and recreated on model changes.

显然,一旦模型发生改变,将无法使用上下文对象连接到数据库检索数据,所以什么样的选择呢?

Obviously as soon as the model is changed it will not be possible to use the context object to connect to the database to retrieve the data, so what are the options?

推荐答案

code首先不支持数据库迁移/演变呢。如果你想要做增量数据库的开发利用模式第(EDMX)用的DbContext生成T4模板的实体设计数据库生成包,它能够创造差异。从模型脚本。

Code first doesn't support database migration / evolution yet. If you want to do incremental DB development use model first (EDMX) with DbContext Generator T4 template and Entity designer database generation pack which is able to create diff. scripts from the model.

 
精彩推荐