本文介绍了能否实体框架4.1的设计师和QUOT;从数据库&QUOT更新模型;选定的实体而已?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的情况:有时一个数据库模式是不是你会考虑系统的信息的一种理想的表示,你可能无法改变它。我们一直在使用实体框架来创建一个更好的概念模型在这样的情况下,以代码代替。这意味着要更新从数据库模型,然后改变它自己,无论是通过设计师或通过.edmx文件,直接使用文本编辑器。

The situation: Sometimes a database schema is not what you would consider an ideal representation of the system's information and you may not be able to change it. We have been using Entity Framework to create a nicer conceptual model to code against in situations like this. This means updating the model from the database and then changing it ourselves, either through the designer or through the .edmx file directly using a text editor.

问题当您更新从数据库模型中,所有的精心所做的更改扔出窗外。这可以增加新的实体一个真正的麻烦,你基本上是被迫通过直接编辑.edmx文件来做到这一点。

The problem: When you update the model from the database, all your carefully made changes are thrown out the window. This can make adding new entities a real hassle as you are basically forced to do it through editing the .edmx file directly.

的问题:有没有办法从从数据库中获取实体框架只更新选定的实体?或者是有可能告诉它添加一个新的实体,当离开模型的其余部分人吗?

The question: Is there a way to get the Entity Framework to only update selected entities from from the database? Or is it possible to tell it to leave the rest of the model alone when adding a new entity?

谢谢!

推荐答案

没有就没有办法使选择性更新内置的设计师。另外,设计者不扔掉所有更改。它通常不碰概念模型(除了某些罕见的情况下它不断地重命名一些关联)和映射,但它总是删除存储模型和新的定义覆盖它。我的工作没有经过修改我的概念模型和映射,并从数据库中运行更新的任何问题。

No there is no way to make selective updates with built-in designer. Also the designer doesn't throw away all your changes. It usually doesn't touch conceptual model (except some rare occasions where it continuously renames some associations) and mapping but it always deletes storage model and override it with new definition. I worked without any problem with modifications to my conceptual model and mapping and running updates from the database.

设计师作品与任何其他在Visual Studio中 - 触摸生成的代码(存储模型)是不支持的功能。一旦你这样做,你不能使用的更新数据库从的了。

Designer works as any other in Visual Studio - touching the generated code (storage model) is not supported feature. Once you do it you cannot use Update from database anymore.

有商业工具更好的模型更新 - 你可以尝试试用

There is commercial tool which probably supports better model updating - you can try a trial.

这篇关于能否实体框架4.1的设计师和QUOT;从数据库&QUOT更新模型;选定的实体而已?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 12:32