The first release of Entity Framework shipped in .NET Framework 3.5 SP1 and Visual Studio 2008. Since then, we have been focused on incorporating your feedback and enabling the scenarios that you wanted us to work on.

The feedback we have received through the betas and release candidate has been instrumental in helping us to get to where we are today; so thank you very much for being a part of the development process.

Today, we are happy to announce the release of Entity Framework 4 as part of the release of Visual Studio 2010 and .NET Framework 4.

Entity Framework 4 builds on Entity Framework 3.5 in the following areas:

 

Development Approach / Design-time Improvements

Model-First Development: In addition to the Database-First approach you had in EF 3.5, Entity Data Model designer in Visual Studio 2010 includes Model-First capability to allow you to start from a model, and generate database based on that model. Read more about this feature here.

Customizable Code-Generation: EF4 leverages the T4 code generation templating engine in Visual Studio. You can now write your own templates that specify exactly how you want code generation to happen; or you can modify the built-in templates such as the Entity Object Code Generator or Self Tracking Entities Code Generator templates. Read more about this feature here. We have also shipped a POCO Template as a separate download available on the Visual Studio Extensions Gallery. Read more about this POCO Template here.

Design-time support for Complex Types (with refactoring): Entity Data Model Designer in VS 2010 lets you define complex types, view complex types in the model explorer tree and refactor existing properties into complex type.

Pluralization: There is now Singularization/Pluralization support such that reverse engineering existing databases will result in models that have more meaningful names for entity types, entity sets and relationships. Read more about this feature here.

Multi-Targeting Support: Entity Data Model Designer and Entity Framework fully support Multi-Targeting capabilities of VS 2010. You can use the designer to continue building your EF 3.5 applications or move forward to EF4. We take care of upgrading / downgrading you to the right EDMX versions and such so that you can use a single IDE to build apps using EF, regardless of the framework version you are targeting.

 

Architectural Concerns & Patterns

Persistence Ignorance & POCO: EF4 allows developers to use their pure domain classes without needing to implement interfaces that deal with persistence concerns. Dynamic proxies are supported for lazy loading and efficient change tracking. Read more about this feature here.

Self-Tracking Entities & N-Tier support: Visual Studio 2010 includes code-generation templates for Self Tracking Entities that allow you to easily build N-Tier applications. There are also new APIs in the product that offer you more control in N-Tier scenarios. Read more about this feature here.

Application Patterns and Testability: EF4 includes an additional interface to help you to write testable code when using the framework. In addition, we have made sure that use of patterns such as Repository and UnitOfWork are possible.

 

Data Access Features

Foreign Key Associations: EF4 includes a new type of association called Foreign Key Association. FK associations allow you to include FK properties in your model and use those as a basis for relationship between entities. Independent Associations from EF 3.5 are still supported but FK Associations will help simplify a few scenarios such as data binding. You can now include foreign keys in your model should you choose to do so. Read more about this feature here.

Lazy Loading: There is now support for automatic Lazy loading. All new projects created using the Entity Designer in Visual Studio 2010 will also have automatic lazy loading enabled by default. Upgraded projects will require this to be explicitly enabled, so that the behavior of your existing projects is preserved unless you explicitly choose to take advantage of this functionality.

More LINQ Operators in LINQ to Entities: More LINQ operators are supported by EF4 such as Contains, Single, SingleOrDefault and DefaultIfEmpty.

CreateDatabase and DDL Provider Services: EF4 includes APIs on ObjectContext that allow you to do database creation based on a model. Provider writers can implement DDL generation capability in their providers that can take advantage of this capability. Read more about this feature here.

Model Defined Functions LINQ support: Model Defined Functions allow you to define composable functions in your model using Entity SQL. You can also expose these functions such that they can be used from LINQ. Read more about this feature here.

EntityDataSource support for QueryExtender, POCO and FKs: EntityDataSource control now includes support for ASP.NET QueryExtender and POCO entities. QueryExtender is a new addition to ASP.NET, which allows you to have more control over the data retrieval query of a Data Source while leveraging LINQ capabilities of EF.

ObjectMaterialized event: Now you can write logic that is executed immediately after an object has been materialized.

Generated SQL improvements for better performance and readability: EF4 includes a lot of optimizations to the queries generated by EF such as removal of unnecessary joins, better translations of certain functions, removal of unneeded levels of nesting, and more. Read more about this here.

Ad-hoc native query support: EF4 supports more ad-hoc query patterns that allow you to run a store query or a command directly. Read more about this feature here.

There are many other smaller improvements we haven’t covered here. We hope that you find these features useful. Be sure to let us know what you think of EF4, and what you’d like to see us do next.

Entity Framework Team