Export (0) Print
Expand All

Entity Framework

The Entity Framework is a set of technologies that support the development of data-oriented software applications. The Entity Framework enables developers to work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code than in traditional applications. For more information, see Introducing Entity Framework.

Overview

Entity Framework is an object-relational mapper (ORM) that reduces the impedance mismatch between the object-oriented world of .NET Framework 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 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 Entity Framework translates the operations into relational database actions.

There are two major layers in an Entity Framework application:

  • The modeling layer

  • The object layer

The modeling layer contains three components:

  • A conceptual model consisting of domain-specific entity types and relationships, based on an Entity Data Model (EDM)

  • A database schema that defines tables and relationships

  • A mapping between the conceptual model and the database schema

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 that 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 Entity Framework.

Mapping and Modeling

There are different ways to create the mapping layer and the object layer:

  • You can use Entity Framework Tools to generate your model from an existing database. This generates a default conceptual model and mapping, which you can customize by using the Entity Data Model Designer. You can also use tools to graphically create a conceptual model by using the Entity Data Model Designer, and then generate a database based on the metadata built by the tool from that model.

  • You can use the Code First development to define your conceptual model in code. The Entity Framework infers the conceptual model based on the object types and additional configurations that you define. The mapping metadata is generated during run time based on a combination of how you defined your domain types and additional configuration information that you provide in code. The model can either be mapped to an existing database or you can generate a new database from your model.

Working with Objects

Entity Framework object layer enables you to do the following:

  • Run queries against the conceptual model.

  • Materialize data returned from the data source as objects.

  • Track changes that were made to the objects.

  • Propagate object changes back to the data source.

  • Bind objects to controls.

See Also

Other Resources

msdn.com/data/ef




Build Date:

2013-10-16
Show:
© 2014 Microsoft