Back to basics: Entity Framework from scratch part 1
June 1, 2010
Let me first introduce to you the Entity Framework, this is an object relational mapping (ORM) framework for the .net Framework
The power of Entity Framework is that you can safely use your data from your database creating a semi virtual object database within your application so changes are not directly in your database.
Using the nosql eliminates the need for converting data to and from the database, as the data is stored in its original object representation and relationships are directly represented, instead of building breath taking views.
Why entity framework, you ask me? After we took so much effort in presenting you the nosql, i find nosql to be a great timesaver, but when it comes to larger amounts of data that needs to be stored, or existing data in a database can soon become to heavy for Nosql.
Let’s say we want to build an application for a animal hospital and collect all our client and list their names, and type of animals and how long they have been a client of ours since we started in 2001.
We have 3 tables: Contact, animal and animaltype and build the following query:
SELECT c.FirstName, e.animalname FROM Animal e INNER JOIN Contact c ON e.AnimalID = c.ContactID WHERE e.Visitrate >= 1 AND e.registerdate >= '2001-01-01'
This is still a small query but you can imagine if you need typical information from the database, the structure can become very heavy. Especially if you are using specific data for one department.
The logical database schemes do not always meet the application needs, for they are often shared for other applications running on the database, like Enterprisesystems. So often the database model does not relate to the application datamodel.
The entity framework contains a datamodel and design and runtime services so you can define your applicationdata and interact, isolate and play with it on abstract level.
In the next part I will give you an example of the use of entity framework