Back to list
Views:   103.8K
Replies:  7

When to use LINQ-to-SQL versus Entity Framework?

My question is this: when should I decide to use LINQ to SQL over Entity Framework?  I my view, LINQ to SQL is far more 'agile' and flexible than Entity Framework. 

I know that Microsoft is totally committed to Entity Framework, but using EF does not come natural to me. I am very experienced with SQL and the whole LINQ to Entities or eSQL API feels awkward: for example, the Attach concept, the Include concept, etc).
Christopher Ronny, Jun 03, 2010
Reply 1
Here's the latest comment I have found from Microsoft regarding Linq2Sql and EF...

Robert Blixt, Jul 08, 2010
Reply 2
Don't forget that there exist solutions outside of Microsoft as well (which has its pros and cons).
Some popular ORMs out there...


Some of the above are commercial others OSS. NHibernate is a popular and mature ORM with origins from Java's Hibernate. There is a comparison between EF4 and NHibernate here. Note that the comparison might be a bit biased, since Oren is a contributor to NHibernate. Nevertheless it is a good read.

Good Luck!

Robert Blixt, Jul 01, 2010
Reply 3
Personallly I would use EF.  EF is a true OR/M where Linq 2 Sql is mostly a SQL obfuscator. With EF you can save/load and manage your objects where with Linq2Sql you still need to know the sql and data structure but you are pretending you don't.
Aaron Burton, Jul 01, 2010
Reply 4
On BASTA! Spring 2010, a presenter said the following:

"Don't choose Linq2Sql if you are starting a new project, the team that developed it, doesn't exist anymore. Choose EF 4.0. This is the way to go. Linq2Sql was merely one possible way which we decided to not follow anymore."
Christian Jacob, Jun 14, 2010
Mohammed, I know they can run side-by-side. However, my question was how, i.e. configuration, start project (WinForms, MVC), Web.config settings, etc. Thanks
May 06, 2010
Reply 5
I wouldn't quite go that far.  The links above are outdated.  Microsoft has made some updates to Linq2SQL in .NET 4.0
Anthony Phillips, Jun 09, 2010
Reply 6
I have not used any of them, but just wanted you to give a heads up if you start using Linq2Sql. It seems as the future for Linq2Sql is very uncertain, and Microsoft might make it obsolete in favor for EF. Something for you to consider when deciding upon which technology to use.


Update on LINQ to SQL and LINQ to Entities Roadmap

Microsoft kills Linq to SQL
Robert Blixt, Jun 09, 2010
Reply 7
The primary difference between the two frameworks is how they handle your models.  That should be clear enough.  ;^)  Just kidding, partly. 

The basic rule of thumb for which framework to use is how to plan on editing your data in your presentation layer. 

  • Linq-To-Sql - use this framework if you plan on editing a one-to-one relationship of your data in your presentation layer.  Meaning you don't plan on combining data from more than one table in any one view or page.
  • Entity Framework - use this framework if you plan on combining data from more than one table in your view or page.
To make this clearer, the above terms are specific to data that will be manipulated in your view or page, not just displayed.  This is important to understand.

With the Entity Framework you are able to "merge" tabled data together to present to the presentation layer in an editable form, and then when that form is submitted, EF will know how to update ALL the data from the various tables.

There are probably more accurate reasons to choose EF over L2S, but this would probably be the easiest one to understand.  L2S does not have the capability to merge data for view presentation.

I hope this answers your question.

King Wilder
King Wilder, Jun 05, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.