I was given a task to develop a web application where there are 600+ users (50 - 100 concurrent users I would say). I decided to develop it using ASP.NET MVC 3 framework. I would like to seek for your expert advise on which data access technology I should
go with, Linq to Sql or Entity Framework?
Data model (database schema) is already completed and it's normalized.
Between the two you should use Entity Framework as it is what is actively being developed and what microsoft is adding more new features to. However, for sections of the application that are data intensive, you might want to use something a little lower
level and I would recommend checking out dapper for those instances http://code.google.com/p/dapper-dot-net/
Check out the chart on there, for data intensive operations dapper out performs linq 2 sql and the entity framework in terms of speed.
I concur on Dapper for a low level ORM with a simple data model. It is awesome, intuitive, and fast. I built a membership and role provider on it and it works like a dream.
Looks like EF is what being used commonly nowadays. I can clearly see that EF is adding an extra layer to the application which might cause some performance issues down the road. If I can afford to write entity and service classes and stored procs (for add,
edit and delete) and consume them within the MVC framework then I don't need to add that extra layer and not to worry about the performance.
I'm going to stick with my approach. But, certainly would like to hear what you all think about that.
The performance difference between sprocs and ef aren't really anything to be concerned about. The only real processing added is the generation of the sql statement (from linq) which only takes a few miliseconds at most. I believe EF also caches these
queries further reducing the time it takes to generate the query.
However, the query generated by EF might not be optimal. In certain cases with complex queries, you might see performance gains in writing the query manually and mapping with Dapper (or another micro orm) as suggested by CodeHobo.
mvc
Marked as answer by ricka6 on Mar 18, 2012 05:58 PM
I can clearly see that EF is adding an extra layer to the application which might cause some performance issues down the road.
I wouldn't make that snap decision without some testing. premature optimization is the root of many evils. Far more important than the overhead of EF is a well designed schema, queries and caching.
mdxfan
Member
4 Points
5 Posts
Linq to Sql or Entity Framework
Mar 16, 2012 02:16 PM|LINK
Hello there,
I was given a task to develop a web application where there are 600+ users (50 - 100 concurrent users I would say). I decided to develop it using ASP.NET MVC 3 framework. I would like to seek for your expert advise on which data access technology I should go with, Linq to Sql or Entity Framework?
Data model (database schema) is already completed and it's normalized.
Your tips are much appreciated.
Thanks in advance.
mvc
ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: Linq to Sql or Entity Framework
Mar 16, 2012 02:18 PM|LINK
In MVC does not matter. See http://msprogrammer.serviciipeweb.ro/2010/03/29/asp-net-mvc-orm-and-viewmodels/
As a preference, I do prefer EF ( code first, support for SqlServerCompact ...)
Dejan_S
Member
413 Points
202 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 02:31 PM|LINK
EF4.1 code first is my recommendation
ryanw51
Contributor
2363 Points
511 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 02:32 PM|LINK
I prefer EF or NHibernate. If you're a beginner, EF would be the better choice.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 03:44 PM|LINK
Between the two you should use Entity Framework as it is what is actively being developed and what microsoft is adding more new features to. However, for sections of the application that are data intensive, you might want to use something a little lower level and I would recommend checking out dapper for those instances
http://code.google.com/p/dapper-dot-net/
Check out the chart on there, for data intensive operations dapper out performs linq 2 sql and the entity framework in terms of speed.
mvc
Blog | Twitter : @Hattan
ryanw51
Contributor
2363 Points
511 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 04:06 PM|LINK
I concur on Dapper for a low level ORM with a simple data model. It is awesome, intuitive, and fast. I built a membership and role provider on it and it works like a dream.
mvc
mdxfan
Member
4 Points
5 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 04:20 PM|LINK
Thanks everyone for your suggestions.
Looks like EF is what being used commonly nowadays. I can clearly see that EF is adding an extra layer to the application which might cause some performance issues down the road. If I can afford to write entity and service classes and stored procs (for add, edit and delete) and consume them within the MVC framework then I don't need to add that extra layer and not to worry about the performance.
I'm going to stick with my approach. But, certainly would like to hear what you all think about that.
Thanks!
mvc
ryanw51
Contributor
2363 Points
511 Posts
Re: Linq to Sql or Entity Framework
Mar 16, 2012 04:30 PM|LINK
The performance difference between sprocs and ef aren't really anything to be concerned about. The only real processing added is the generation of the sql statement (from linq) which only takes a few miliseconds at most. I believe EF also caches these queries further reducing the time it takes to generate the query.
However, the query generated by EF might not be optimal. In certain cases with complex queries, you might see performance gains in writing the query manually and mapping with Dapper (or another micro orm) as suggested by CodeHobo.
mvc
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Linq to Sql or Entity Framework
Mar 16, 2012 04:48 PM|LINK
I wouldn't make that snap decision without some testing. premature optimization is the root of many evils. Far more important than the overhead of EF is a well designed schema, queries and caching.
mvc
mdxfan
Member
4 Points
5 Posts
Re: Linq to Sql or Entity Framework
Mar 17, 2012 04:00 AM|LINK
Thank you all for your advices.