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! )
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 wellCode First
Ebook is available today (Nov 21, 2011) with print coming soon here
Kindle should be available by Wednesday (Nov 23, 2011) on Amazon.com 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.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
Hi, just bought the e-book from O’Reilly. I hope it helps me better understand EF Code First. I have read some of your articles and they helped me a lot.
I do have book on this
Rowan and you are doing a great job here. Congrats on being the goto on EF. Look forward to your future work.
Regards,
Kim(Kman)
Looking forward to the DbContext book. any ETA for release?
Tiger, we gave the book to OReilly about 3 weeks ago for production (first PDF prior to final review). On the last book they turned that around within a week. This time they’ve run into staffing & other snafus and it’s still in the queue. 🙁