What's New (Entity Framework 4.1)

This latest release of the Entity Framework is focused around increasing productivity and enabling code-centric (“Code First”) development. The two major new areas of this release are:

  1. Simpler and more intuitive API surface (“the DbContext API”);

  2. Code First database development.

The DbContext API

At the heart of the EF productivity improvements are two new types, DbContext, and DbSet<TEntity>. These types are built on top of ObjectContext and ObjectSet<TEntity>. They provide a simplified API for carrying out the most common tasks, while allowing you continued access to the underlying types when needed.


DbContext is a simplified alternative to ObjectContext and is the preferred method for interacting with a database unless you need features that are only present in ObjectContext. DbContext can be used with all 3 methods of Entity Framework development: code-first, model-first, and database first.


This method is a simplified alternative to ObjectSet<TEntity>, and is used to perform CRUD operations (Create, Retrieve, Update and Delete) against a specific type from the model.

ADO.Net DbContext Generator T4 Templates

The ADO.NET DbContext Generator generates persistence-ignorant entity types, also known as "plain-old CLR objects” (POCO types), and a derived DbContext type that contains DbSet<TEntity> properties for each type in the model.


DbContext will automatically validate entities before saving them to the database. Validation is performed based on model facets as well as DataAnnotations. Entities can also be validated “on demand”.”

Code First

Code First allows you to define your model using C# or VB.Net classes. You can do additional configuration by adding attributes to your class definitions and members, or by using the DbContext API. You can generate a database schema from your model, or map it to an existing database.”

Community Resources

There are a number of blogs that discuss these features, including the following.

Productivity Improvements for Entity Framework describes how to use the productivity api to do “Code First” development.