Views: 103.8K
Replies: 7
Archived
|
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 1Here's the latest comment I have found from Microsoft regarding Linq2Sql and EF...
http://msdn.microsoft.com/en-us/data/bb525059.aspx Robert Blixt, Jul 08, 2010
|
|
Reply 2Don't forget that there exist solutions outside of Microsoft as well (which has its pros and cons).
Some popular ORMs out there... NHibernate, http://nhforge.org/ Subsonic, http://subsonicproject.com/ LightSpeed, http://www.mindscape.co.nz/products/lightspeed/ LLBLGEN, http://www.llblgen.com/defaultgeneric.aspx 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 3Personallly 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 4On 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 5I wouldn't quite go that far. The links above are outdated. Microsoft has made some updates to Linq2SQL in .NET 4.0
http://damieng.com/blog/2009/06/01/linq-to-sql-changes-in-net-40 http://blog.linqexchange.com/index.php/linq-to-sql-changes-in-net-4-0/ Anthony Phillips, Jun 09, 2010
|
|
Reply 6I 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.
Reference: Update on LINQ to SQL and LINQ to Entities Roadmap http://blogs.msdn.com/b/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx Microsoft kills Linq to SQL http://ayende.com/Blog/archive/2008/10/31/microsoft-kills-linq-to-sql.aspx Robert Blixt, Jun 09, 2010
|
|
Reply 7The 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.
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
|