有关在.NET 4 - 不信任实体框架投票? [英] Entity Framework Vote of No Confidence - relevant in .NET 4?

查看:222
本文介绍了有关在.NET 4 - 不信任实体框架投票?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定的ORM的一个大项目,并决心去ADO.NET实体框架,特别是其新版本附带的.NET 4。在我搜索的信息,EF我偶然发现的不信任ADO .NET Entity Framework的投票这我不知道如何利用。

I'm deciding on an ORM for a big project and was determined to go for ADO.NET Entity Framework, specifically its new version that ships with .NET 4. During my search for information on EF I stumbled upon ADO .NET Entity Framework Vote of No Confidence which I'm not sure how to take.

不信任投票是一段写于2008年说服微软听取了EF v1的具体批评。

The Vote of No Confidence was written sometime in 2008 to convince Microsoft to listen to specific criticism for EF v1.

目前尚不清楚,在不信任投票中作出的声明是否仍有效(在.NET 4中),如果他们是认真的就够用了其他的解决方案。 NHibernate的是一个成熟的选择,但我不知道它带来什么问题。我一般对一个小姐的解决方案更倾向于,主要是因为我可以指望的整合与VS和他们的开发支持。

It's not clear whether the claims made in the Vote of No Confidence are still valid (in .NET 4) and if they're serious enough to use other solutions. NHibernate is a mature alternative, but I don't know what problems it brings. I'm generally more inclined towards a Ms solution, mainly because I can count on integration with VS and on their developer support.

我会AP preciate 例子如何在不信任投票中提到的问题,在现实世界中的项目的影响。 更重要的是,在权利要求书作出仍有相关的EF用于.NET 4?

I would appreciate examples of how the problems mentioned in the Vote of No Confidence affect in real world projects. More importantly, are the claims made there still relevant in EF for .NET 4?

推荐答案

我一直觉得,很多东西下垫的不信任投票是使用EF就好像它是一个NHibernate克隆的尝试。实在不行,甚至在EF 4尝试使用EF就好像它是一个NHibernate的山寨货很可能会以失败告终,虽然你可能没有之前得到远一点。作为一个简单的例子,大多数人在最小的基础上使用LINQ的NHibernate的,如果有的话,而我不认为你可以在有生产力的EF的所有的,除非你使用LINQ相当严重。

I've always felt that much of what underlay the "vote of no confidence" was an attempt to use the EF as if it were an NHibernate clone. It isn't, and even in EF 4 attempting to use the EF as though it were an NHibernate knockoff is probably going to end in failure, although you may get a little further before failing. As a trivial example, most people use LINQ in NHibernate on a minimal basis, if at all, whereas I don't think you can be productive in EF at all unless you use LINQ quite heavily.

在另一方面,我一直很成功地使用EF 1就其自身而言,并设法不让要求人们在博客文章取得使它成为我工作的方式。我期待用许多在EF 4的新功能,但我很高兴能工作在一个结构良好的EF 1项目的任何时间。 (对于这个问题,我很高兴与NHibernate的工作,过了,就不会批评它不采​​取行动,如EF)

On the other hand, I've been quite successful at using the EF 1 on its own terms, and have managed to not allow claims people make in blog posts to get in the way of making it work for me. I look forward to using many of the new features in EF 4, but I'd be happy to work on a well-structured EF 1 project any time. (For that matter, I'm happy to work with NHibernate, too, and wouldn't criticize it for not acting like the EF.)

所以,我想建议,在一个有点微妙的方式,那才可以决定是否在不信任投票中作出的声明仍然有效(在.NET 4中)...,你必须首先决定如果这些说法是的永远有效的为您和方式工作的若邻您的个人理解/ R是硬连接到NHibernate的,那么EF 4很可能还是会显得二流给你。如果,另一方面,你愿意去学习工作的EF方式,那么很可能连EF 1会显得比你听说过。

So I'm trying to suggest, in a somewhat delicate way, that before you can decide if "the claims made in the Vote of No Confidence are still valid (in .NET 4)..." you must first decide if those claims were ever valid for you and the way you work. If your personal understanding of O/R is hard-wired to NHibernate, then EF 4 is probably still going to seem second-rate to you. If, on the other hand, you're willing to learn the EF way of working, then probably even EF 1 will seem better than you've heard.

要解决不信任索赔直接,同时检查其实质内容,哪些在EF 4已经改变:

To address the "no confidence" claims directly, and examine both their substance and what's changed in EF 4:

实体过分专注于数据ASPECT导致退化实体体系结构:

INORDINATE FOCUS THE DATA ASPECT OF ENTITIES LEADS TO DEGRADED ENTITY ARCHITECTURES:

这是实体框架的实体数据模型的一种误解。 (或者说,意见分歧,如果你preFER)。但无论哪种方式,这是一个功能,不是一个错误。实体框架是围绕的数据服务,而不仅仅是O /特别ř建模的更一般的情况而设计的。从数据服务返回的实体把行为导致了CORBA式的灾难。不像奥姆斯你在哪里,在一定程度上,坚持与任何类型散发出来的ORM黑盒的,和你预期投射到业务类型实体框架模型。在这种情况下,的映射的实体类型甚至不会被实现。

This is a misunderstanding of the Entity Framework's entity data model. (Or, a difference of opinion, if you prefer.) But either way, it's a feature, not a bug. The Entity Framework is designed around the more general case of data services, not just O/R modeling in particular. Putting behaviors on entities returned from a data service leads to a CORBA-style disaster. Unlike ORMs where you are, to some degree, stuck with whatever type comes out of the ORM blackbox, with the Entity Framework model you are expected to project onto business types. In this case, the mapped entity types will never even be materialized.

这是实体框架模型和许多其他奥姆斯之间的实质性区别。就个人而言,我发现从O / R映射分离业务的行为比结块在一起相当多的清洁剂。你不必同意这个想法,但它显然是一个设计决策,而不是监督。

This is a substantive difference between the Entity Framework model and many other ORMs. Personally, I find separating business behaviors from O/R mapping to be quite a bit cleaner than lumping them together. You don't have to agree with this idea, but it is clearly a design decision, not an oversight.

超额code需要处理LACK延迟加载:

EXCESS CODE NEEDED TO DEAL WITH LACK OF LAZY LOADING:

在EF 4,是好还是坏,有延迟加载。

The EF 4, for better or worse, has lazy loading.

我说:是好是坏,因为延迟加载使得它非常容易产生过多的数据库查询。它工作正常,只要你保持在引擎盖下是怎么回事密切关注,但大多数人不这样做。我觉得投影以是懒加载,预先加载,或明确载入最一个更好的选择的时间

I say "for better or worse" because lazy loading makes it very easy to generate excess database queries. It works fine so long as you keep a close eye on what's going on under the hood, but most people don't do that. I find projection to be a better alternative to lazy loading, eager loading, or explicit loading most of the time.

不过,有些时候延迟加载是方便。所以,我很高兴看到它加入EF 4。

Still, there are times when lazy loading is convenient. So I'm glad to see it added in EF 4.

共享,规范模型违背了软件最佳实践:

SHARED, CANONICAL MODEL CONTRADICTS SOFTWARE BEST PRACTICES:

这是很难知道该怎么利用这一点,因为一些配套文本甚至没有连贯的英语,如:

It's hard to know what to make of this, as some of the supporting text isn't even coherent English, e.g.:

在易出故障的典范模型的方法并不困难,缺乏沿着实体框架的线条精细的模具。

The failure-prone canonical model approach wasn’t difficult for a lack of elaborate tooling along the lines of the Entity Framework.

本节的似乎的暗示实体框架强加某种要求,或至少强烈的偏见,对使用单一,标准数据模型的复杂系统。我不知道我同意,但是很难讲,因为在本节中没有任何具体的例子。所以,我会告诉你我自己的偏见关于这个问题,你可以同意或不同意我:

This section seems to suggest that the Entity Framework imposes some kind of requirement, or at least strong bias, towards using a single, canonical data model for a complex system. I'm not sure I agree, but it's difficult to tell, given the lack of any specific example in this section. So I'll tell you my own biases on the subject, and you can agree or disagree with me:

它往往是一个错误使用一个单一的模式对于大型系统,根据系统实际有多大。在实体框架没有要求您然而,使用一个单一的模式。而另一方面,实体框架,特别是在第1版,不出去了它的方式可以很容易地结合多个模型。

It is often a mistake to use a single model for a large system, depending upon how large the system actually is. Nothing in the Entity Framework requires you to use a single model, however. On the other hand, the Entity Framework, especially in version 1, does not go out of its way to make it easy to combine multiple models.

现在,一个单一的,大型应用程序对于一个复杂的系统可以是一个极大的错误,因为一个单一的,大型的数据模型。因此,这将是不正确的实体框架,使之容易许多微小的车型组合成一个过大的应用程序;这将只是另一个替换一个问题。

Now, a single, large application for a complex system can be as big of a mistake as a single, large data model. So it would not be correct for the Entity Framework to make it easy to combine many tiny models into one overly large application; that would simply replace one problem with another.

在另一方面,我认为这有一定道理,可以很容易建立一个大型的系统,在一个适合的问题域的方式划分的服务。我认为,WCF数据服务,从实体框架的独立技术,但其中一个支持实体框架非常好,都对这项有益的。

On the other hand, I think it does make sense to make it easy to build a large system out of services partitioned in a way which suits the problem domain. I think that WCF data services, a separate technology from the Entity Framework, but one which supports the Entity Framework very well, are useful for this.

我不认为实体框架可能,在未来的版本中,更容易将两个或三个型号结合成一个单一的应用程序在必要时。现在你可以做到这一点,但有一些涉及体力劳动。但正如我上面所说的,我不希望通过促进/鼓励创作过大的应用程序的修理过大的数据模型的问题。

I do think that the Entity Framework could, in some future version, make it easier to combine two or three models into a single application when necessary. You can do this now, but there is some manual work involved. But as I said above, I wouldn't want to "fix" an issue of an overly large data model by facilitating/encouraging creation of an overly large application.

LACK持久性无知会导致业务逻辑要难读,写和修改,造成开发和维护成本,以增加一个夸张率:

LACK OF PERSISTENCE IGNORANCE CAUSES BUSINESS LOGIC TO BE HARDER TO READ, WRITE, AND MODIFY, CAUSING DEVELOPMENT AND MAINTENANCE COSTS TO INCREASE AT AN EXAGGERATED RATE:

这部分使索赔,我觉得错误的:

This section makes claims which I find erroneous:

实体框架鼓励贫血领域模型反模式被阻止在实体类中包含业务逻辑。

The Entity Framework encourages the Anemic Domain Model anti-pattern by discouraging the inclusion of business logic in the entity classes.

见上面。我认为,实体类型的工作是在对象空间关系的空间之间的映射。按照单一职责原则,这些类型应该只需要时,他们唯一的工作变动进行修改。如果业务流程发生变化,那么这是无关的O / R映射责任。也许其他奥姆斯限制强加给分离这些职责的一个技术壁垒。没关系弯曲规则时的技术规定,如果设计纯度的成本过高。但是,我坚决赞成行为较少的实体类型的方法。

See above. I think that the job of the entity types is to map between relational space in object space. Per the Single Responsibility Principle, these types should only need to be modified when their sole job changes. If business processes change, then this is a responsibility unrelated to O/R mapping. Perhaps limitations of other ORMs impose a technical barrier on separating these responsibilities. It's okay to bend rules when technology dictates, if the cost of design purity is excessive. But I strongly favor the approach of behavior-less entity types.

在当前状态下,外汇基金的实体类不能有效的单位数据库的独立测试。

In its current state, EF entity classes cannot be effectively unit tested independently of the database.

<一个href="http://stackoverflow.com/questions/2372030/testing-ef-sql-server-based-application-with-in-memory-sqlite/2372137#2372137">This是错误的。谁写这根本不明白他们在说什么。没有任何一个单元测试触摸DB,以往,许多涉及到EF

This is just wrong. Whoever wrote this didn't understand what they were talking about. None of our unit tests touch the DB, ever, and many involve the EF.

在到目前为止,因为这部分的题目的实质推移,对于EF 4的变化现在可以有完全持久性无知的实体类型,如果这能帮助你的设计。不过,从实体框架的上话的最早版本,你已经能够投射到波苏斯。因此,在需要时持久性的无知一直是可用的。其对实体类型的持久性的无知本身可以变化的跟踪与持久性昧对象。可能在某些情况下是有用的。但它的情况下比单元测试,这减轻了点项目文件中受到了很大的影响的假索赔的基本较小的子集。

In so far as the substance of the title of this section goes, there is a change for EF 4. It is now possible to have entirely persistence-ignorant entity types, if that helps your design. However, from the earliest version of the Entity Framework on words, you have been able to project onto POCOs. So persistence ignorance has always been available when required. Having persistence ignorance on the entity types themselves allows change tracking with a persistence-ignorant object. That may be useful in some cases. But it's a substantially smaller subset of cases than the bogus claims about unit testing, which lessens the impact of the point the document makes by a lot.

使用源控制过度合并冲突在团队环境:

EXCESSIVE MERGE CONFLICTS WITH SOURCE CONTROL IN TEAM ENVIRONMENTS:

其实就是合并XML那么难吗?如果是这样,也许应该寻找到一个新的合并工具。我不觉得这是有问题的。

Is merging XML actually that difficult? If so, perhaps one should look into a new merge tool. I don't find this problematic.

不过,这里有一个真正的问题,虽然,再次,这是一个很大比文件要求更窄。而不是重复自己,我就为您指出 href="http://blogs.teamb.com/craigstuntz/2010/02/03/38542/">我的职务。

However, there is a real issue here, although, again, it's a lot more narrow than the document claims. Rather than repeat myself, I'll just point you towards my post on that subject.

在EF 4,可以使用code-首款车型,而不是XML的模型,以模型分成许多不同的文件。

In EF 4, one can use code-first models rather than XML models in order to split up a model into many different files.

这篇关于有关在.NET 4 - 不信任实体框架投票?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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