Compartilhar via


What is Entity Framework?

I know this is out of sequence for this blog, but I really needed to get a better grasp on what the Entity Framework is, so I did some research on it, and rather than waste good knowledge, I figured I’d write about it now and we can come back to it later. At its simplest form, the Entity Framework is kind of a translator between the “object model” of the database (tables grouped by task and likeness of the data) and the application that is using the data from the database (which typically uses OOP structure, so you have methods, properties and events). So, think of it as a way of using a programming model structure to converse, in programming-type language, with a set of database tables. This is an overly simple way of looking at it, of course, but then again, that’s my goal with this blog!

The first thing we need to look at is an Entity then, and understand what it means in this context, as this is the fundamental unit of the Entity Framework. An Entity is actually an instantiation of an Entity Type, much like an object is an instantiation of a class. Basically, an Entity Type maps to a database table and what it contains, for instance a Person table, so the Entity would be the Object instantiated from this Table.

The other concept to grasp is that of the Relationship – again, a Relationship is an instantiation of a Relationship Type. A Relationship Type is an association between Entities. As an example, when you have the above-mentioned Person Table, but you also need data from another table, such as Employment to confirm if someone is indeed employed, you create a Relationship between the Tables.

To put this in “pictures”, if you open the Query Designer, the boxes would be the Entities and the Relationships would be the lines between them when you draw a query out. Again, this is overly simplistic, but it should help you to get your head around the Entity Framework. If you want a much more detailed dissertation, I suggest looking at Julie Lerman’s Webpage (she has written two books on the subject) at https://thedatafarm.com/main.aspx. Another good resource I have found is Frans Bouma’s blog, specifically the post here.

Comments

  • Anonymous
    April 20, 2011
    The comment has been removed

  • Anonymous
    April 21, 2011
    Glad it helped you!

  • Anonymous
    June 23, 2011
    Thanks, it also helped me a lot. Keep blogging. Thanks again.

  • Anonymous
    July 17, 2011
    Thanks, it helped you!

  • Anonymous
    July 30, 2011
    ty sir

  • Anonymous
    August 14, 2011
    thanks

  • Anonymous
    September 28, 2011
    Helped a bunch, Thanks!

  • Anonymous
    October 31, 2011
    Does Entity Framework is replacing  LINQ? Thanks

  • Anonymous
    February 16, 2012
    I agree with James. I wanted a brief outline of what it is, and this article provided it. Thanks.

  • Anonymous
    June 28, 2012
    This article is very much needed for beginners

  • Anonymous
    October 15, 2012
    Hey Ed, Your Blog is really helpful (especially for Beginners)... Thanks for sharing... Will first share this Thread on some Social Networking Sites... Thank you once again.. :)