Category Archives: Book

After 3 Years, Devs are Still Finding Programming Entity Framework 2ed Useful


I spent a year writing the 1st edition of my book Programming Entity Framework and then another year revising it for EF4 which resulted in the 2nd edition. After that Microsoft released DbContext (which sits on top of the ObjectContext for simpler coding) and Code First that sat on top of EF4. EF5 was mostly a consolidation that also took advantage of 3 new features in .NET 4.5 (enums, spatial data and query caching). VS2012 brought some nice designer improvements and a default DbContext/POCO code generator. EF6 mostly adds some advanced features to what’s already there.

But what hasn’t changed much are things like LINQ to Entities, security, ESQL, how transactions work (small change coming in EF6), databinding, code generation,and most importantly the Entity Framework internals. It is understanding the internals that give you real power over Entity Framework – not relying on the #efhelp hashtag, stackoverflow or the kindness of strangers.

It was really nice to see this brand new 5-star review of my 2nd edition book (screenshot below).

Not only does this book cover explain Entity Framework from a programming point of view, but it pulls back the covers to explain the many options available. The many comprehensive real life examples that Julie Lerman provide make this a programming Bible for Entity Framework. Whether you are using views, stored procedures, user defined functions, the T4 generator, Entities or POCO’s, Julie Lerman can help you come up with the solution that works for you.”

I still believe that a combination of the shorter focused books Programming Entity Framework DbContext and Programming Entity Framework Code First with the 2nd edition book for deeper understanding of specific topics – almost as a reference now – packs a “one-two” punch for entity framework.

And as you may know, I’m making my bigger investment in Pluralsight videos now. I have 10 videos alone on Entity Framework already along with one which is a Beginner’s training on Unit Testing & Test Driven Development.

I wrote a blog post recently on the recommended order for watching those Pluralsight videos along with suggestions to help you decide which is correct for you.

I still keep thinking about updating one or more of the Programming Entity Framework titles, but while each of the few dozen strongly worded pleas I have received to do so are tempting, a few dozen still does not justify the effort.


EF Code First Book (Ebook) 1/2 price today (April 25) at O’Reilly

O'Reilly Media

Deal of the Day

Discover Our 5-Star Ebooks for 2013

Save 50% on the Top 25 – Today Only


We keep a running tally of our top-performing, five-star titles. These are the books that have most impressed and earned praise from readers like you. We’re now sharing the list with the added incentive of a special offer: for one day only, get these five-star ebooks for 50% off.

Ebooks from are DRM-free. You get free lifetime access, multiple file formats, and free updates. Sync with Dropbox — your files, anywhere.

View the 5-Star Rated Ebooks   →

Use discount code: DEAL
This deal expires April 25, 2013 at 11:59pm PT and cannot be combined with other offers. Offer does not apply to Print, or "Print & Ebook" bundle pricing.

DbContext Book is Online!

The digital version of Programming Entity Framework: DbContext is now available directly from O’Reilly Media at

This was a nice surprise since production only sent the final manuscript to the print production department yesterday. Smile

The print version might be another week or so.

Amazon will most likely have the kindle version available sooner than they are able to ship printed copies.

DbContext book status

largercoverThings are moving again! Our publisher had a production backup due to some staffing changes. Rowan and I are now reviewing the first version of the production manuscript (that is after they’ve converted our Microsoft Word documents into a single doc formatted for the final printing). We’ve got a PDF copy of that and are reading through and marking up any last changes we’d like to have fixed in the manuscript.

We’ve been told that the book will head to the printer (and digital production) on Feb 23rd. If it’s like the Code First book, the digital versions (PDF, mobi (aka kindle) and ebook from  O’Reilly and kindle from Amazon) will be available quickly with the print books to follow a week or so after that. Amazon has the book listed as “shipping March 8th” although I’m hoping that we see it sooner than that.


Downloads for Code First book are online

The downloads samples are available for Programming Entity Framework: Code FIrst on the downloads page of the book’s website (

Rowan and I are busy working on the next book (Programming Entity Framework:  DbContext API) right now. Hopefully it will go into production in the next week or two.

Here are links to get a copy of the book:

Programming Entity Framework 2nd edition
From Ebook (PDF, .mobi, ebook) and print here
Amazon  –> Print  Print version     Kindle:  Kindle Version
Plenty of other sources as well

Programming Entity Framework: Code First
From Ebook (PDF, .mobi, ebook) and print here
From Amazon: Kindle and print are available: direct link to Amazon page

Programming Entity Framework 2nd Edition vs Code First Edition

I’ve had tweets and emails from readers asking if there is any point to reading the 2nd edition of Programming Entity Framework if they are only planning to use Code First and DbContext.

(Before answering, I want to add a disclaimer that my response is not geared towards my desire to increase royalties in order to pay off my mortgage someday. That wouldn’t be possible unless I put Harry Potter or Steve Jobs names on the cover. Hey, now there’s an idea! Smile )

Yes, the 2nd edition is completely relevant although there are bits within there that will be irrelevant.

Getting your hands on the book(s):

2nd edition
You can get print & ebooks (PDF/mobi (for Kindle) etc) directly from the publisher here
Amazon  –> Print  Print version     Kindle:  Kindle Version  
Plenty of other sources as well

Code First
Ebook is available today (Nov 21, 2011) with print coming soon here
Kindle should be available by Wednesday (Nov 23, 2011) on with print coming shortly after that: direct link to Amazon page

To begin with, I suggest reading this blog post about the difference between what’s in Code First/DbContext and the core EF APIs that are part of .NET 4 (Code First and DbContext are now “The Entity Framework”).

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.

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.

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.

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.

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.