What's New in Entity Framework 4.1
ADO.NET Entity Framework 4.1 includes two new features:
·
DbContext API
The DbContext API is
a simplified abstraction over ObjectContext and a number of other types that
were included in previous releases of the ADO.NET Entity Framework. The
DbContext API surface is optimized for common tasks and coding patterns.
DbContext can be used with Database First, Model First and Code First
development.
DbSet<TEntity>
This
method is a simplified alternative to ObjectSet,
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 derivedSystem.Data.Entity.DbContext type that contains System.Data.Entity.DbSet properties for each type in the model.
Validation
DbContext automatically validates entities before saving them to the database.
Validation is performed based on model facets as well as on data annotations.
Entities can also be validated on demand.
·
Code
First
Code First is a
new development pattern for the ADO.NET Entity Framework and provides an
alternative to the existing Database First and Model First patterns. Code First
is focused around defining your model using classes, these classes can then be
mapped to an existing database or be used to generate a database schema.
Additional configuration can be supplied using Data Annotations or via a fluent
API.