Getting Started With Entity Framework

April 10, 2008

Getting Started With Entity Framework

In this post and on the following I’m going to write about the
ADO.NET Entity Framework.
To those who wait for the design pattern posts, I’m going to continue
writing about design patterns as well.

Lets start at the beginning.
What is this entity framework that you probably heard about?
The entity framework is a framework built on top of ADO.NET.
It was made to support development of data-oriented software applications.
It is currently in beta 3 and suppose to be released with Service Pack 1 for
visual studio 2008.
The entity framework tries to addresses the impedance mismatch between
object-oriented programming and data storage.
If you ask yourself what is the impedance mismatch, the answer is a phrase
from electrical engineering that describe the difficulty of one system to handle
inputs from another system.

Entity Framework Models
There are 3 main players in the framework:
1. A conceptual model – the entities and their relations in the system.
2. A logical model – the store schema definition which describe the tables and
    their foreign key constraints. It is connected to the physical model – the data
    storage itself.
3. The mapping – maps the conceptual model into the logical model.

Entity Framework Schemas
The framework contains 3 types of XML files to address the main players:
Conceptual schema definition language (.csdl) – for the conceptual model.
Store schema definition language (.ssdl) – for the logical model.
Mapping specification language (.msl) – for the mapping model.
Using these files, the framework build a set of entities/objects from the conceptual
model. These entities communicate with the data storage through the logical model.
This way the developers gets an object oriented model which can query
and update data as entities.

Entity Framework Design
In the next diagram you can see the currently design of the entity framework.

Entity Framework Design 

System.Data.EntityClient Namespace
I wrote about the framework layers so lets go up in the diagram.
The classes in the System.Data.EntityClient namespace consist of data provider
which is storage independent. Therefore the framework can address variety of
databases and not just SQL server like LINQ to SQL.
The EntityClient also contains the ObjectContext class which is the class that is
being derived by the framework in order to build the entities container.

Entity SQL
The Entity SQL or E-SQL is the language to work with the conceptual entity
schema. The entity framework knows how to translate the E-SQL you write
to storage specific queries by the chosen data provider.

LINQ to Entities
LINQ to entities is a way to work against the conceptual entity schema without
E-SQL language. In this way you can address the entities with LINQ and you
wouldn’t have to learn E-SQL or use it’s features.

Entity Framework Installation
How to install the entity framework beta 3 and it’s tools?
You should download both the framework and the tools and install them in
the the following order:
First install the  ADO.NET Entity Framework Beta 3.
After the framework is installed, install
ADO.Net Entity Framework Tools December 07 CTP to add the framework
tools to visual studio 2008.

In the next post of this series I’ll start to dive into how you can use the
entity framework.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>