Announcing the release of Entity Framework 4

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

Comments

  • Anonymous
    April 12, 2010
    Thank you for the information your provide.

  • Anonymous
    April 12, 2010
    This is great news that this is released!  Do you have any details on just what made it into the release?  And if any changes have been made since CTP 3?

  • Anonymous
    April 16, 2010
    Pls. I'd like to know when Code Only will be released as well as if EF 4.0 has full support for SQL Server CE 3.5

  • Anonymous
    April 17, 2010
    @John Jones, The final release of EF has the same set of features that were in the RC.  When it comes to the feature CTPs, that means the final release of EF includes self-tracking entities but not the poco template (which is available from the online gallery) or code-only. @Tolu, We do not have a final release date for Code Only.  We are still evolving it which is why it's available only in CTP form.  We will continue to keep you all apprised of the status as soon as we can. As far as Sql CE goes, the EF definitely does support it.  I'm not entirely certain what you mean about "full support", though.  Is there some specific feature you are looking for that isn't working or something?

  • Danny
  • Anonymous
    April 17, 2010
    Hi, I have a question about stored procedure. In EF 4.0 there is support for Complex type for stored procedure. But what if stored procedure return Multiple result Set. Create Procedure Proc1 As DECLARE @Test int Select @Test = CustomerId from Customers where CustomerName = 'Test1'; Select @@error as ErrorCode , @Test As CustomerID When i do this EF 4.0 always return first result.

  • Anonymous
    April 17, 2010
    The comment has been removed

  • Anonymous
    April 28, 2010
    test of auto-comment routing2

  • Anonymous
    May 13, 2010
    Thanks Danny, I've been trying to use SQLCE with Code Only. I'm wondering if this is possible. The ContextBuilder seems to be choking on the SQLCE Connection. Pls. advise.

  • Anonymous
    May 14, 2010
    Hi, Is there a way to get notified about the exceptions handled within stored procedures?

  • Anonymous
    May 16, 2010
    Code Only not supported SqlCe + EF?

  • Anonymous
    May 16, 2010
    I got {"Unable to determine the provider name for connection of type 'System.Data.SqlServerCe.SqlCeConnection'."} in code SqlCeConnection scc = new SqlCeConnection(sqlCeConnnectionStr);                        MyContext oc = ContextBuilder.CreateDefaultContext<MyContext>(new SqlCeConnection(sce.LocalConnectionString));            oc.CreateDatabase(); MyContext from samples in this blog. Connection string is "Data Source=./My.sdf;Password=password;Encrypt=true;File Mode=Exclusive;"

  • Anonymous
    May 25, 2010
    @Michael The SQL CE Provider currently doesn't include the DDL support required for CreateDatabase(), our teams are currently working on this and hope to have support in the next release of the SQL CE Provider.

  • Rowan
  • Anonymous
    May 31, 2010
    Sorry if this isn't the correct place to post a question! I've started looking at using EF 4 as an alternative to LINQ to SQL. One thing I've noticed, when using Include() to load extra data with an entity, EF always translates this to a left outer join when it could often use an inner join, i.e. when the ID column is not nullable and there is a foreign key setup. Is there a way to get it to use inner joins instead? Or does it not actually make a difference performance wise?

  • Anonymous
    June 04, 2010
    In regards to @Jinal's comment above, on the EF supporting multiple result sets, do you have some sample code using the Translate() method you mentioned? Maybe website describing the steps? I just did my first EF,  .net 3.5 RIA services app using Silverlight and had to do all these workarounds to handle multiple results sets in the EF. The complex type is a great addition though just looking for code to handle the multiple result sets. Thanks

  • Anonymous
    June 23, 2010
    Hi, Why does not EF use multiple result sets in its final SQL query ? Wouldn't that be more efficient? Thanks.

  • Anonymous
    July 06, 2010
    Will there be support for enumerations in POCO?