Search code examples
.netentity-frameworkado.netenterprise-library

Relationship between Enterprise Library and Entity Framework - MS offerings of ADO.NET technologies


I'm reading this very interesting book on Entity framework (EF) which is an Object Relational Mapper(ORM) offering from Microsoft. Our of curiosity, I started to backtrack all the offerings from Microsoft which is used to connect to SQL Server database. Microsoft uses its proprietary ADO.NET data provider technology to conect to database in all its offerings.

Almost a decade ago, I had used Microsoft application blocks in my project for connecting to SQL Server database. To use it I used to reference the MS Application block DLLs in my project directly. Since then so many other things have also come up. Objective of all of them is same - reduce the repeatitive code developers write to do DB operations. This problem is more prominent every time when you start a new project from scratch.

So I started investigating all the options that will be available to me whenever I start a new project from scratch. How these offerings stack against each other? Are they same or they are a gradual enhancement of the same age old ADO.NET technology with EF being the latest offering? Here are the options I tried to explore:

  1. Manually using various ADO.NET classes available in System.Data.SqlClient namespace (by referring System.Data.dll - Available since .NET Framework 1.x)
  2. Referring Microsoft.ApplicationBlocks.Data.dll assembly in your project and executing DB queries.
  3. Enterprise Library from Patterns and practices team of Microsoft.
  4. LINQ to SQL (Released with .NET v3.5)
  5. Entity Framework (Released with .NET v3.5 Service Pack 1)

All these options can be a point of confusion once you enter into ADO.NET world. It will be helpful if anyone can throw a birds eye view on these offerings.


Solution

  • Off hand - you should write off Microsoft.ApplicationBlocks.Data and Enterprise Library.

    LINQ to SQL supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's good for a RAD (rapid application development) scenario. I believe MS still supports it, but I don't think they are doing active development on it. I haven't used it or seen it used on any projects I've been on in years.

    As you mentioned Entity Framework is an ORM and its much more powerful than LINQ to SQL. The following SO post has a lot of information on the differences.

    Another option to consider is Dapper. Dapper is a micro-orm and very fast. Here is some good analysis of Dapper vs. ADO.NET in this SO post: Why should one use Dapper ? Also can anyone comment on Dapper Vs ADO.NET Pros and Cons

    Personally, I use Entity Framework or Dapper when I'm building an application. If it's a very large application with complex mapping requirements - then I normally opt for Entity Framework. Otherwise, I stick with Dapper.

    I may use straight ADO.NET if I am building a service or some utility that doesn't require any sort of mappings.

    Read this EntityFramework VS pure Ado.Net