实体框架(.NET)先进模型的往返建模? [英] Entity Framework (.NET) Round-Trip Modelling with Model First?

查看:124
本文介绍了实体框架(.NET)先进模型的往返建模?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个项目,我想首次使用实体框架
。我在Lerman / Miller的书籍中阅读了许多信息,MSDN中的
,ADO.NET博客以及有关DbContext API和代码优先迁移的最新
开发的stackoverflow
自EF 4.3以来可用的功能。
由于特别是后者真的很棒,我想知道在此期间是否可以做同样的工作模范第一中心?
可以根据可视EDMX设计器(而不是代码)在
之后进行迁移,从而创建代码和数据库?



我发现一个很近的链接(2012-04)说,它不是(在EF 4.3):
使用具有模型优先方法的EF4迁移工具



其次,我发现旧代码和数据库表的信息当试图从EDMX设计器重新生成它们时,
是否被覆盖?



但是我提到的信息是关于电动工具:
http:// blogs .msdn.com / b / adonet / archive / 2012/04/09 / ef-power-tools-beta-2-available.aspx


逆向工程师代码首先
此命令允许一次性生成Code First映射用于存在数据库。 [..]
•多次运行此命令将覆盖任何以前生成的文件,包括对生成的文件进行的任何更改


这个限制是否仅针对电动工具逆向工程师代码首先
,还是扩展到EDMX设计师,特别是Model First
方法?



此外,在上述文章中,我发现:


查看实体数据模型(只读)
在Entity Framework设计器中显示Code First模型。
•这是模型的只读表示;您不能使用设计器更新Code First模型。


同样的问题也适用于此。



所以现在有一种完全往返建模的方式,没有数据丢失
(代码和数据库),并保持EDMX文件可写,最好在
Model First之后? / p>

从这个(已经或有计划的)支持的EF的哪个版本,哪个
版本的.NET应该被定位(4.0足够?)和这将使用
Visual Studio 2010 Professional?你可以粗略估计你可能会实现的日期
吗?



这当然是非常棒的和巨大的突破!我想我只能
大概想象这将是多少工作,我知道你已经完全
工作在你的极限。我想感谢你迄今为止的美好工作
,并鼓励你保持这一点。

解决方案

如果我正确理解您的问题是在EF Designer的迁移之后(即更新设计器中的模型并使数据库逐步更改)。目前不支持这一点,我们积压的是我们的解决方案,但是我们没有针对特定版本的具体计划。我们需要解决的一个问题是,我们是否应该集成/扩展现有的代码优先迁移功能来与EF Designer配合使用,还是需要更多的设计师关注的东西。
显然事情可以改变,但在这个阶段我不会期待我们在接下来的6个月内开始研究这个功能。除此之外,它将取决于我们看到人们要求的功能...所以我将在 http://数据中创建一个新功能.uservoice.com ,并让人们投票。
〜Rowan


I am currently working on a project where I want to use the Entity Framework for the first time. I read much information in the books of Lerman/Miller, in MSDN, the ADO.NET blog and here on stackoverflow about the most recent developments regarding the DbContext API and the Code First Migrations capabilities available since EF 4.3. Since especially the latter are really great, I wondered whether in the meantime it is possible to do the same working "Model First" centered? Is it possible to do migrations based on the visual EDMX designer (instead of the code) after creating the code and the database from it?

I found a pretty recent link (2012-04) saying that it is not (in EF 4.3): Using EF4 migration tool with model-first approach

Secondly, I found information that old code and database tables are overwritten when trying to regenerate them from the EDMX designer?

But the info I refer to is about the Power Tools: http://blogs.msdn.com/b/adonet/archive/2012/04/09/ef-power-tools-beta-2-available.aspx

Reverse Engineer Code First This command allows one-time generation of Code First mappings for an existing database. [..] • Running this command multiple times will overwrite any previously generated files, including any changes that have been made to generated files

Is this restriction only specific to the Power Tools Reverse Engineer Code First or does it expand to the EDMX designer in general, especially the "Model First" approach, too?

Furthermore, in the above article I found:

View Entity Data Model (Read-only) Displays the Code First model in the Entity Framework designer. • This is a read-only representation of the model; you cannot update the Code First model using the designer.

And the same question applies here.

So is there currently a way with full round-trip modelling without data-loss (code and database) and keeping the EDMX file writable, preferrable following "Model First"?

From which verson of EF on is this (already or planned to be) supported, which version of .NET should I target then (4.0 sufficient?) and will this work with Visual Studio 2010 Professional? Could you give a rough estimate for the date you may will have implemented this?

This would of course be awesome and a huge breakthrough! I think I can only roughly imagine how much work this would be and am aware that you are fully working at your limit already. I want to thank you for your great work so far and encourage you to keep it up.

解决方案

If I understand your question correctly you are after Migrations for the EF Designer (i.e. update the model in the designer and have the database incrementally changed). This isn’t currently supported, it is on our backlog to address but we don’t have specific plans for a particular release. One of the things we need to work out is whether we should just integrate/extend the existing Code First Migrations feature to work with the EF Designer or whether we need something that is a bit more designer focused. Obviously things can change, but at this stage I wouldn’t be expecting us to start working on this feature in the next 6 months. Beyond that it’s going to depend on what features we see folks asking for… so I would create a new feature on http://data.uservoice.com and get folks voting on it. ~Rowan

这篇关于实体框架(.NET)先进模型的往返建模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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