Archive for March, 2014

Why to use entity framework(EF)

March 26, 2014 Leave a comment

As we know that there are numbers of data access technology available these day like ADO.NET , LINQ to SQL and NHIBERNATE that working fine then why does any of us want to adopt new technology , why should I adopt or learn this new technology or rather what problem they sort out that existing technology could not efficiently . So lets explore these technology the way these let us connect and work with database then the answer of why to use EF will come out.

Entity Framework vs ADO.NET


  1. You write code against Database object like table , store procedure etc.
  2. You managing the connection life like (open, close) to database .
  3. If you change databse in future then you have to change your code specific to that provider .

Entity Framework(EF)

  1. You write data access code against domain object rather than database object
  2. Entity framwork managing the whole things like creating database connection , executing query , processing result , tracking changes to the object so you are totally focusing on you r business logic rather than database things hence amount of code you have to write for database operation is reduced .
  3. In EF , query is written the form of LINQ ,Entity SQL and then it translated by provider to specific back end query syntax so if you change database in future then there are not much impact.

So by going through above comparision between EF and ADO.NET its clear that EF has great potential as data access technology over ADO.NET 🙂

Entity Framework vs LINQ to SQL:


  1. LINQ to SQL support only SQL SERVER.
  2. LINQ to SQL class supoprt one-to-one map with database objects like Employee class can be mapped only with Employee table.

Entity Framework

  1. Entity framework has support for full provider .
  2. You can map your domain class with numbers of table using feature TPT , TPH of EF.
  3. There are number of way you can use EF like Database first , Model first, code First.
  4. It is open source and Microsoft soft has long term strategy for this technology.

So if you reading from top top to this line then I think it is clear to you now that WHY we would use Entity framework over other technology .

I would be happy to hear your feedback , correction in this article ,enhancement to this article .


Categories: Entity framework Tags:
%d bloggers like this: