Book Review: Programming Entity Framework, Second Edition

by mosessaur| 02 January 2011| 0 Comments

About the book

Title: Programming Entity Framework 2nd Edition
Publisher: O'Reilly Media
URL: http://oreilly.com/catalog/9780596807252
Book website: http://learnentityframework.com/
ISBN: 978-0-596-80726-9
Chapters: 27 + 3 Appendices | ~900 pages
Author:
Author’s blog: http://thedatafarm.com/blog/
Overall rating: 9.70 out of 10
This is the second edition of the book totally revised for Entity Framework 4.0 on VS2010 1st edition was released Jan 2009. this 2nd new edition released August 2010.

Personal Opinion

I can’t do anything but strongly recommend this book. It is almost everything you might need about Entity Framework 4.0. Great walkthroughs and samples in C#. However there are few snippet in VB.Net that shows different syntax of doing things between C# & VB.Net.

More...

Getting Started with Entity Framework 4.0 Screencast Recorded session from Cairo Code Camp - Part 5

by mosessaur| 24 September 2010| 0 Comments

About Part 5

Fifth part is about 9:45 min in length. Part 5. Covers EDM -Entity Data Model- showing its elements (SSDL, CSDL & MSL). Also this screencast shows how to query your conceptual model using LINQ to Entities.

More...

Getting Started with Entity Framework 4.0 Screencast Recorded session from Cairo Code Camp - Part 4

by mosessaur| 07 August 2010| 0 Comments

About Part 4

Fourth part is about 10 min in length. Covers how to implement table per hierarchy inheritance model (TPH) with Entity Framework 4.0

More...

Inheritance and Associations with Entity Framework Part 3

by mosessaur| 01 October 2008| 1 Comments

On part 1 and part 2 I explored how to apply 2 different inheritance models (TPH & TPT) in Entity Framework. In this part I'm going to demonstrate associations between 2 base entities. And how to filter end properties to return specific type (sub entity). Download the sample.

Review Association Ends:

In previous part when I added department tables to the entity model diagram, an associations between Person and Department entities was automatically defined. This relation actually demonstrate the relation between Administrator and Department. It is one-to-many relationship where one person can be administrator of one or many departments.

A collection of Departments is created on Person table and therefor it is inherited on all sub entities! But this make no sense, as a student or instructor has nothing to do with this collection. Beside on the other end at Department a property of type Person is created -I renamed it to Administrator-, while this shouldn't be just any Person, this Person must be of type Administrator.

A few modification should take place in here. The existing association should be deleted and the association ends should be define between Administrator Entity and Department Entity. To do that follow the following steps:

More...

Inheritance and Associations with Entity Framework Part 2

by mosessaur| 29 September 2008| 5 Comments

In the previous part I discussed Table-per-Hierarchy Inheritance, in this part I'll go through Table-per-Type Inheritance model. There is a video demonstrating this model if you wish to watch. Here I'll update my previous sample with new entities that demonstrate the Table-per-Type Inheritance model. For the differences between 2 models and definitions return to 1st part. The updated sample can be downloaded from here.

How to define a model with Table-per-Type Inheritance:

At the beginning I'll explore the database design for this subject, and explain why Table-per-Type must be used to model the inheritance:

More...

Inheritance and Associations with Entity Framework Part 1

by mosessaur| 24 September 2008| 3 Comments

In this multi parts series I'll explore how to build inheritance with Entity Framework showing 2 different approaches of inheritance in Entity Framework. Beside that I'll show how to build simple association between 2 entities and show how to provide custom code to retrieve other parts of the relation when inheritance is applied.

My plan not to exceed 3 parts as the subject is not that huge, it is just the demonstration with screen shots that will make the post large that is why I divided it to multi part. I am not good at screen casts beside I don't have a software license to produce one.

Inheritance Types in Entity Framework:

There are 2 models of Inheritance in Entity Framework and they both actually depends on the database design:

  • Table-per-Hierarchy Inheritance: One table in storage to maintain data for all the types in an inheritance hierarchy. So basically you have one table in database, but different types in your Entity Model that inherits from a base class and all mapped to that table. This post will focus on this type of Inheritance.
  • Table-per-Type Inheritance: Separate table in storage to maintain data for each type in the inheritance hierarchy. That means you might have several tables with one-to-one relationships. Each table is mapped to single Entity in the model. But there is a base Entity that is mapped to the very base table. This is going to be the subject of my next part of this short series. Till then you can watch this video about it.

About the Sample:

The sample I am going to demonstrate here with screen shots is taken from MSDN sample in the links specified above. I found them much clear and easy to demonstrate beside I wasn't able to come out with much simpler sample idea.

More...