Feature Post

Top

EF4: ADO.NET Entity Framework v4.0

ADO.NET: Entity Framework v4.0 EF4

EF, sometimes called EF4 because it forms a part of .NET v4.0, is a relatively new ORM growing fast in Microsoft Developer Community. It is expected to leave NHB behind; at this time nHibernate is has an edge that it is mature; but it does come with a bit of learning curve where HBM mapping files are concerned.

FIG1: System
Why Use? The primary goal of the is to raise the level of abstraction for data programming, to eliminate the mismatch between data models and between languages that application developers would otherwise have to deal with.

Entity Data Model (EDM) is defined by CSDL, SSDL, and MSL. Conceptual Schema Definition Language(CSDL) is a design template used to declare and define entities, its associations; the classes are generated using CSDL. If you do have Visual Studio IDE then it would do that for you. Store schema definition language(SSDL), contains formal description of the database that persist data. And Mapping specification language(MSL), used to connect the types declared in CSDL to database metadata.
FIG2: Model Classes Generated by IDE


Large models and entity splitting?
Why would you split entity in EF? Entity Splitting involves mapping a single entity in the conceptual layer to multiple tables in the store.

And sometimes with big models say 500+ tables with alot of database relation you might encounter problems with performance. Therefore in general as a rule of thumb "you should start thinking about breaking up a model when it has reached 50-100 entities". So then you think about handling large datastore. Here is how you would split your edmx files?

EF4 performance and benchmark(1000+ tables)?
Gergely Orosz did a performance test between nHibernate and Entity Framework, which is worth checking out. Measurement was done by implementing two simple applications using the same table structure and doing the same operations on the same data. But at this time the designer response starts fluctuating with 150+ tables and you may experience something that you wouldn't want.

EF4 Security Considerations?
MSDN article provides a list of security considerations that are specific to developing, deploying, and running EF based applications.


I believe its the lack of maturity of the product that some see current state of EF as a concern. Its only a matter of time for EF to prove itself. The points that are raised are:
  • Inordinate focus the data aspect of entities leads to degraded entity architectures
  • Excess code needed to deal with lack of lazy loading
  • Shared, canonical model contradicts software best practices
  • Lack of persistence ignorance causes business logic to be harder to read, write, and modify, causing development and maintenance costs to increase at an exaggerated rate
  • Excessive merge conflicts with source control in team environments
They expect the future of the entity framework, would be fully equipped with Lazy Loading, TableValueFunctions, Less-Xml.

VS2010-Beta 2 includes some great new features and updates for the Entity Framework 4 and ADO.NET Data Services 4.

A good place to start? Depending on what you are most interested in, you should consider getting started with this quickstart that illustrates a series of tasks; or look into the topics in Getting Started. These tasks are designed to help become familiar with the EF.

You can find samples here at Documentation Samples website for Visual Studio 2008. Although EF comes with VS2008 SP1; but if you must, then download it from here.

Besides that EF4, when used with ASP.NET MVC, creates Model classes automatically, which helps reduce the development time radically; this article goes way deeper to build n-tier apps with EF4.

However, at the end of the day the real deal is about Performance - and Delighted Customer; well, and in terms of project-growth, any tool that we use "requires attention".