Entity Data Model (EDM) In Entity Framework

Entity Data Model (EDM) In Entity Framework


In the  entity framework I wrote an introduction about the framework.
Today I’m going to dive into the heart of the framework – the entity data model (EDM).

What is the Entity Data Model (EDM)?
The EDM is a specification for defining the data used by applications built on the
entity framework.

Entity data model (EDM) desgin:


Entity Data Model


EDM Layers
There are three layers in the EDM:


  • Conceptual layer

  • Mapping layer

  • Logical layer


The layers help to bridge the gap between the relational database schema and
the wanted entities in the application.
Every layer is represented in a XML schema.
The conceptual layer is defined by a Conceptual Schema Definition Language
(CSDL). The CSDL defines the entities and the relations between the entities
as expected from the business logic of the application.
The mapping layer is defined by a Mapping Schema Language (MSL).
The MSL defines the mapping between the conceptual layer and the logical layer.
The logical layer is defined by a Store Schema Definition Language (SSDL).
The SSDL is a representation of the relational database or part of it.

Mapping Example
Lets generate a one to one mapping between a database and a business logic
object model.
From the Add New Item menu, choose the ADO.NET Entity Data Model and
add it to your project:
Add new EDM
The result of choosing to add the EDM is a wizard that help you to build the EDM.
First, choose the model content. It can be generated from a database or from an
empty model:
Choose Model Content 
Then, choose your data connection in the same way you choose data connections
(by using a connection string or generating a new one):
Choose Data Connection 
A screen with the database tables, views and stored procedures will be open.
You can either choose everything or choose the relevant objects for the module
you build.
Choose Database Objects
Choose Database Tables
In a one to one mapping you will choose everything and therefore click the
Finish button to generate the EDM file in the project.
The result:
EDM Designer 
You can use the model browser view to look at the generated entities, tables and
In the next post I’m going to demonstrate the XML files types and how they are

source: http://blogs.microsoft.co.il/gilf/2008/04/18/entity-data-model-edm-in-entity-framework/