InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

What’s New in Entity Framework 4.0 Beta?

Posted by Abel Avram on May 19, 2009

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
.NET ,
Data Access
Tags
ADO.NET ,
ADO.NET Entity Framework

Entity Framework 4.0 Beta 1 – aka EF V2 - delivered with .NET 4.0 Beta 1 contains a list of important improvements: Customization of Code Generation, Lazy Loading, N-tier Support, POCO Support, DDL Generation, Query Customization and others.

The major improvements introduced in EF 4.0 are:

  1. Customization of Code Generation – Integration with the ADO.NET Entity Framework Designer and T4 Templates in Visual Studio to provide developer controlled code generation.
  2. Small things that make development of applications simpler – Adding things like Pluralization and Singularization in the model, lazy loading, and more stored procedure mapping make building applications that use the Entity Framework much easier.
  3. Customizing Queries – Adding support for existing LINQ operators, recognizing a larger set of patterns with LINQ, writing model defined functions along with the ability to use these in LINQ, and a number of other ways to create and customize queries.
  4. SQL Generation Readability Improvements – Improving the readability, along with TSQL performance optimizations, of the generated queries to make it much easier to understand what is happening

Detailing some of the improvements existing in EF 4.0:

N-tier Development

One important aspect of N-tier development is the ability to exchange entity state between the server and the client. Diego Vega, Program Manager ADO.NET Entity Framework, details this further:

What you actually need is to:

  1. Infer what the state changes are that need to be applied from a disconnected graph.
  2. Communicate those changes to the persistence layer.

To help with that, EF 4.0 contains the following API calls:

  • ObjectContext.ApplyOriginalValues
  • ObjectStateManager.ChangeObjectState
  • ObjectStateManager.ChangeRelationshipsState

Besides the low-level API, EF contains self-tracking entities:

Self-tracking entities know how to do their own change tracking regardless of which tier those changes are made on. As an architecture, self-tracking entities falls between DTOs and DataSets and includes some of the benefits of each.

The ADO.NET team will make available a T4 template (not included in Beta) to generate classes and extension methods for ObjectContext.

Model First

Visual Studio 2010 has to ability to generate a DDL and create a database to store the entity data model. The developer has complete control over the entire process being able to customize the DDL, or to select the database he desires, or fine tune the mapping process.

Lazy Loading

In EF 4.0 deferred/lazy loading of related entities is supported by default by setting the property ContextOptions.DeferredLoadingEnabled to true. Lazy loading works with code-generated entities as well as POCO ones. Lazy loading is turned off by default but this setting can be customized.

POCO Support

In .NET 3.5, EF objects needed to either inherit EntityObject or implement one of the interfaces: IEntityWithKey, IEntityWithChangeTracker andIEntityWithRelationships. That introduced strong awareness of the persistence layer spoiling the domain model. All these restrictions have been removed in EF 4.0 allowing for completely transparent persistence.

Resolves Vote of No Confidence? by Al Tenhundfeld Posted
  1. Back to top

    Resolves Vote of No Confidence?

    by Al Tenhundfeld

    So, do you think this release of EF will address all of the major issues raised in the vote of no confidence?

    It seems the DDD model/objects first approach will be much easier, and POCO support should make persistence ignorance and TDD possible.

Educational Content

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.