您的位置:首页 > 其它

[Entity Framework书籍推荐]Programming Entity Framework 2nd Edition vs Code First Edition

2012-03-03 14:40 573 查看
The CF book (Programming Entity Framework: Code First edition) is a relatively short book (175 pp) that covers how Code First enables you to create an entity data model that Entity Framework can use directly from your domain classes. It explains how Code First works by convention and how to use the Data Annotations and Fluent API to configure the model when convention don’t interpret your classes as you intended. the book also goes into detail on how Code First “database initialization” feature works and how to control it. In one of the final chapters, we cover some advanced features of Code First.

《Code First edition》相对而言是一本比较短小的书(175页),主要介绍Code First是如何使得你直接从你的域对象创建能被Entity Framework框架使用的实体数据模型。它解释了Code First如何通过约定工作,以及当约定无法准确你域类的配置意图时如何通过使用Data Annotations和Fluent API来协助配置域模型。本书也详细描述了Code First的“database initialization”如何工作以及怎样控制它。在本书的最后章节我们介绍了一些Code First的高级特性。

That’s the entirety of the book. So what it’s doing is showing you how to achieve a model without the designer, replacing only a very small part of what you learn in the 900 page book (the part it replaces is how to achieve a model using the designer). Even in the 2nd edition chapters that cover advanced modeling, you learn more than just how to click here and type there in the designer. You get a thorough education on the effects. For example, you’ll learn how to build inheritance into your model in the designer, but then you’ll look at (or write if you want) code that uses this inheritance hierarchy and helps you understand how it works, the affect on your application and on your data. In the Code First book, you’ll learn how to achieve the same inheritance hierarchies using code first (convention, annotations and fluent) but we do not spend very much time on how this affects your applications.

以上是那本书的全部内容。它要做的便是告诉了如何在没有设计器的情况下获得一个域模型,取代另一本900页书中的一小部分内容(被取代的部分是介绍如何通过设计器来获得域模型)。在《Programming Entity Framework》的第二版,你将不仅仅学到如何在设计器中做一些简诸如点击编辑之类的简单操作。你将全面学习内部是如何起作用的。比如,你将学习如何在设计器中的域模型上建立继承,与此同时你将查看到实现这一继承层次的内部代码以帮助你更好地理解它是如何工作的以及对你的应用程序和数据起着什么影响。在《Code First》一书中,你将学习如何通过使用code first中的约定,annotation和fluent配置来实现同样的继承体系。

The book that Rowan and I are writing right now will focus on the DbContext API including the new state management and Validation API. This will also be narrowly focused. DbContext gives you easier access to the most common coding patterns that are a little trickier to achieve with the underlying ObjectContext. A great example is that in Chapter 21 of 2nd edition, I have some extension methods to make it easier to get to tracked objects. DbContext now has the Local method so you won’t need those. The underlying behavior of EF does not change.

本书将更多地关注DbContext API,包括新的状态管理和验证API。DbContext使得你更容易获得大多数通用的功能,而这些通过DeContext底层ObjectContext来获取会相对更棘手些。在《Programming Entity Framework》第二版的第21章节有个很好的例子, 我通过一些拓展方法使得获取被跟踪的对象更为容易。不过现在DbContext有了这些本地方法因而你并不再需要它们。但EF底层的行为却没发生变化。

We were avoiding writing another book that might end up at 1200 pages (and take forever to write) were we to include all of the information in once place. Instead, the goal was to give you the specific information that was missing in as short and digestible a format as we could. The short books may be all you want. If you are interested in the deeper aspects of how EF works, how to control it, how to deal with exceptions, performance, transactions, application patterns etc etc, then you can learn those things in the 2nd edition.

在编著CF时,我们避免写一本可能厚达1200页包含所有信息的书。取而代之,编写CF这本书的目标是给你特定的具体的信息。如果你对这些深入方面有兴趣,诸如EF是如何工作的,怎样控制它,怎样处理异常,性能,事务,应用程序模式等,那么你可以在《Programming Entity Framework》第二版中学习到这些内容。

When the DbContext book is finished, our plan is to put together a cook book of application DbContext for use with DbContext & Code First that are relevant to those you’ll find with ObjectContext and EDMX (POCOs & EntityObjects) in the 2nd edition.

I hope this will help you with your journey.

感谢博友qouoww对《Code First Edition》一书的翻译,详情见其博客

《Code First Edition》pdf下载地址:下载

《Programming Entity Framework 2nd Edition》pdf下载地址:下载

E文源自 Julie Lerman‘s Blog

(补充:上面的两本书都出自于该作者。Julia是作者的正式名称,而Julie是他的小名,即他的著作都署名Julia)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: