Updated Version of “What is Entity Framework”?

I’ve received feedback that lets me correct a few errors in my original draft that I posted (https://ricksaling.wordpress.com/2011/01/14/entity-framework-code-first-release/). I’ve incorporated most of the feedback, so here’s the result.

This topic is designed to answer two questions:

  • What is Entity Framework, in a nutshell
  • What are its major components, one level down?

This topic is the top node in the MSDN documentation for the upcoming “Code-First” release.


Entity Framework

This release of Entity Framework introduces a new “productivity api”, and enables ”Code First” development. For more information, see What’s New

The Entity Framework is an “Object-Relational Mapper”, which reduces the “impedance mismatch” between the object-oriented world of .Net developers, and the world of relational databases. It enables developers to primarily interact with an application’s conceptual model, using familiar object-oriented techniques. In the Entity Framework you can work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern yourself with the underlying database tables and columns where this data is stored. Developers can issue data access operations against the conceptual model, and EF takes care of translating the operations into relational database actions.

Overview

There are two major layers in an Entity Framework application:

  1. The modeling layer; and
  2. The object layer.

The modeling layer contains three components:

  1. A conceptual model consisting of domain-specific entity types and relationships, based on an Entity Data Model (EDM);
  2. a database schema that defines tables and relationships; and
  3. a mapping between the conceptual model and the database schema.

The Entity Framework uses the mapping component to transform operations against entity objects such as create, read, update, and delete, into equivalent operations in the database.

The Entity Framework object layer contains typed Common Language Runtime (CLR) objects, which reflect the entities and relationships defined in the conceptual model. These objects can be consumed by programming languages. The exact format of the types is controlled by options you provide to the Entity Framework.

Mapping and Modeling

There are three different ways to create the mapping layer and the object layer.

  1. “Database First”: starting with an existing database, generate a conceptual model from it, using the Entity Data Model Tools. In this case a default conceptual model and mapping are generated, which you can customize using the Entity Data Model Designer. For more information, see Tutorial: Creating a Conceptual Model from an Existing Database using Tools.
  2. “Model First”: graphically create a conceptual model first, using the Entity Data Model Designer, and then generate a database based on the metadata built by the tool from that model. For more information, see Tutorial: Creating a Conceptual Model using Tools .
  3. “Code First” (new in this release of Entity Framework): define your object model in code. The Entity Framework supports 2 scenarios:
    1. It can infer a conceptual model based on the object types and additional configurations that you define. The mapping metadata is generated during runtime based on a combination of how you defined your domain types and additional configuration information that you provide in code. The Entity Framework generates the database as needed based on the metadata..
    2. You can map your object layer directly to an existing database.

For more information, see Tutorial: Creating a Conceptual Model using Code and Mapping and Modeling a Conceptual Model .

Working with Objects

The Entity Framework object layer provides facilities to do the following:

  1. execute queries against the conceptual model;
  2. materialize data returned from the data source as objects;
  3. track changes that were made to the objects;
  4. propagate object changes back to the data source; and
  5. bind objects to controls.

In this Section

What’s New

Mapping and Modeling a Conceptual Model

Applying Additional Configurations to a Conceptual Model

Working with Entities

Querying with LINQ to Entities

See Also

ADO.NET Entity Framework


Advertisements

About Rick Saling

I work at Microsoft as a Senior Programmer Writer, currently documenting Entity Framework. Prior to that I did database design work for many years. Non-work interests include outdoors (hiking, scrambling, backpacking), political issues, travel, learning languages (currently working on Turkish).
This entry was posted in Code-First, CTP5, Entity Framework and tagged , , , , . Bookmark the permalink.

One Response to Updated Version of “What is Entity Framework”?

  1. Pingback: Tweets that mention Updated Version of “What is Entity Framework”? | Entity Framework, Data, Languages -- Topsy.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s