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
- You write code against Database object like table , store procedure etc.
- You managing the connection life like (open, close) to database .
- If you change databse in future then you have to change your code specific to that provider .
- You write data access code against domain object rather than database object
- 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 .
- 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:
LINQ to SQL
- LINQ to SQL support only SQL SERVER.
- LINQ to SQL class supoprt one-to-one map with database objects like Employee class can be mapped only with Employee table.
- Entity framework has support for full provider .
- You can map your domain class with numbers of table using feature TPT , TPH of EF.
- There are number of way you can use EF like Database first , Model first, code First.
- 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 .