Entity Framework (Code-First Release)

This is a preview of the top-level MSDN topic for the new “Code-First” release of Entity Framework. The goal of this topic is to give a very high-level overview of Entity Framework, and to mention briefly what’s new (there is a separate “What’s New” topic that I’ll post next week, most likely).

Note that none of the links work, and the formatting is a bit off because the content has gone directly to the web (via this blog) rather than through Microsoft’s publishing process for MSDN.

You can post feedback in the comments section, and I will consider incorporating parts of it in the final version of this topic, if appropriate.

Entity Framework (Code-First Release)

This release of Entity Framework introduces a set of enhancements and features that increase productivity and enable ”Code First” development. For more information, see What’s New
The Entity Framework is an “Object-Relational Mapper”, which is intended to reduce 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.
There are three major data components in an EF application:
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 layer.
Entity Framework generates a run-time object layer by transforming the types and relationships defined in the conceptual model into typed Common Language Runtime (CLR) objects, so that they can be consumed by programming languages. The exact format of the generated types is controlled by options you provide to the Entity Framework.
Mapping and Modeling
There are three different ways to create the conceptual model, the database schema, and the mapping between them.
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 will 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.. For more information, see Tutorial: Creating a Conceptual Model using Code and Mapping and Modeling a Conceptual Model .
Working with Objects
Entity Framework provides tools that automatically generate an object layer based on the conceptual model. The object layer code contains definitions of classes corresponding to the entity types, and an object context, which is a container for in-memory 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. handle concurrency;
5. propagate object changes back to the data source; and
6. 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


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.

1 Response to Entity Framework (Code-First Release)

  1. Pingback: Updated Version of “What is Entity Framework”? | Entity Framework, Data, Languages

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s