Entity Framework 4.1

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

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 (Entity Framework 4.1).

  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 (Entity Framework 4.1).

  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 to an existing database, and the corresponding conceptual model and mapping will be inferred.

For more information, see Tutorial: Creating a Conceptual Model using Code (Entity Framework 4.1) and Mapping and Modeling a Conceptual Model (Entity Framework 4.1).

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 (Entity Framework 4.1)

Mapping and Modeling a Conceptual Model (Entity Framework 4.1)

Applying Additional Configurations to a Conceptual Model

Working with Objects( Entity Framework 4.1)

Querying (Entity Framework 4.1)

See Also

Concepts

ADO.NET Entity Framework