问题描述
我已经用Visual Studio 2010创建了Entity Framework 4模型,并从中创建了一个数据库。现在,我发现自己添加了新属性(具有默认值),更改了列的文档,更改了列的名称,多次更改了列的类型。所有不需要太多额外工作即可自动完成的任务(以我的拙见)。每次我执行从模型生成数据库并丢失表数据。
I have created a Entity Framework 4 model with Visual Studio 2010 and generated a database from it. Now I found myself adding new properties (with default values), changing documentation of columns, changing names of columns, changing types of columns several times. All tasks that do not require much "extra work" in order not to be possible to be achieved automatically (in my humble opinion). Everytime I did "Generate Database from Model" and lost of course the table data.
有没有一种方法可以更新数据库的体系结构,比如说-保留表数据没动过?也许与某些用户交互,尤其是在更改类型等时?还是很难以可靠的方式实现此功能?
Is there a way just to update the database's architecture so to say - leaving the table data untouched? Maybe with some user interaction especially when changing types etc.? Or would this functionality be simply too difficult to be realized to work in a reliable way?
预先感谢!大卫,干杯
推荐答案
Noam Ben-Ami-MSFT1(Microsoft员工)在如下:
Noam Ben-Ami - MSFT1 (Microsoft Employee) answered my question at http://social.msdn.microsoft.com/Forums/en-us/adodotnetentityframework/thread/3adc080f-ee8c-4104-be29-95b2fb3fabe9 as follows:
它包括为设计人员进行迁移而不是删除/
It includes a database generation workflow for the designer that does migration, rather than drop/create.
此发布按原样提供。没有任何保证,也没有授予任何权利。
This posting is provided "AS IS" with no warranties, and confers no rights.
我还没有测试过该工具,但我想该信息可能对其他人也很有价值。
I haven't tested the tool yet, but I guess the info might be valueable for others, too.
这篇关于实体框架:“从模型更新数据库”;而不是“从模型生成数据库”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!