ProAnswers.org

Entity Framework vs LINQ to SQL

When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what’s the difference?

The way I understand it, the Entity Framework (when used with LINQ to Entities) is a ‘big brother’ to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can’t do on its own?

1 Like
	LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.



	LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.



	This is a good introductory article on MSDN: [Introducing LINQ to Relational Data](http://msdn.microsoft.com/en-us/library/cc161164.aspx)

L2S is tightly coupled - object property to specific field of database or more correctly object mapping to a specific database schema
L2S will only work with SQL Server (as far as I know)
EF allows mapping a single class to multiple tables
EF will handle M-M relationships
EF will have ability to target any ADO.NET data provider

The original premise was L2S is for Rapid Development, and EF for more “enterprisey” n-tier applications, but that is selling L2S a little short.

LINQ to SQL is the quick-and-easy way to do it. This means you will get going quicker, and deliver quicker if you are working on something smaller.
Entity Framework is the all-out, no-holds-barred way to do it. This means you will take more time up-front, develop slower, and have more flexibility if you are working on something larger.