实体框架:“从模型更新数据库”;而不是“从模型生成数据库” [英] Entitiy Framework: "Update Database from Model" instead of "Generate Database from Model"

查看:82
本文介绍了实体框架:“从模型更新数据库”;而不是“从模型生成数据库”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用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员工)在 http://social.msdn.microsoft.com/Forums/en -us / adodotnetentityframework / thread / 3adc080f-ee8c-4104-be29-95b2fb3fabe9 如下:

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:


我们已经建立了实体设计器数据库功能包装以支持这一点。您可以在这里下载: http://visualstudiogallery.msdn .microsoft.com / en-us / df3541c3-d833-4b65-b942-989e7ec74c87

它包括为设计人员进行迁移而不是删除/

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.

这篇关于实体框架:“从模型更新数据库”;而不是“从模型生成数据库”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆