Sunday, February 22, 2009

What is EDM??

An Entity Data Model (EDM) is a client side data model and is core of the Entity framework. This model is different from database model we know. Database model represents the schema of database tables whereas EDM represents the structure of your business objects.

Let us take a small example, suppose we have a table 'Person' that is linked with 'PersonalDetails' and 'SalesPerson'.

Using the above scheme, if we need to retrieve a set of SalesPerson along with their personal detils then the query will be like this:

SELECT SalesPerson.*, PersonalDetails.*, Person.* FROM Person INNER JOIN PersonalDetails ON Person.PersonID = PersonalDetails.PersonID INNER JOIN SalesPerson ON Person.PersonID = SalesPerson.PersonID

Now u, if we had option to change the shema in order to suite our coding and if we can convert it to something like this:

Here all the fields of PersonalDetails are the part of Person and SalesPerson entity is getting derived from Person, very much similar as in Object Model.

Now the LINQ query to fetch the data will be:

from p in People.OfType<salesperson> select p

This is the simple example of how the Entity Framework can remove the pain of having not only to interact with the database, but also to translate the tabular data into objects.

When working with the Entity Framework, you will use a particular implementation of an EDM. In the Entity Framework, an EDM is represented by an EDMX file at design time that is split into a set of three XML files at runtime.

We will cover three xml files in our next section

No comments:

Post a Comment