Entity Framework VS LINQ to SQL VS ADO NET with stored procedures

0 votes

How would you rate each of them in terms of:

  1. Performance
  2. Speed of development
  3. Neat, intuitive, maintainable code
  4. Flexibility
  5. Overall

I've always loved ADO.NET and stored procedures since I love my SQL, but I just tried out Linq to SQL and was amazed at how quickly I could write out my DataAccess layer. As a result, I've chosen to invest some time fully studying either Linq to SQL or EF—or neither?

I just want to make sure that none of these technologies have a significant defect that would make my research time pointless. For instance, the performance is poor; it's great for straightforward programmes but has its limits.

Can someone please help me with this?

 

Sep 14 in Database by Kithuzzz
• 12,240 points
32 views

1 answer to this question.

0 votes

First off, if you're starting a new project, use Entity Framework ("EF") instead of Linq to SQL because it now generates far better SQL (more like Linq to SQL does) and is easier to maintain ("L2S"). Since.NET 4.0 has been released, I believe Linq to SQL to be an old technology. MS has been quite transparent about not pursuing additional L2S development.

1) Performance

Answering this is challenging. You will discover that the performance of all three technologies is roughly comparable for the majority of single-entity operations (CRUD). To use EF and Linq to SQL to their greatest potential, you do need to be familiar with how they operate. You might wish to have EF/L2S "compile" your entity query for high-volume actions like polling queries so that the framework doesn't have to keep regenerating the SQL, else scalability problems may arise. (view changes)

Because you don't have to marshal the data over the wire to the ORM to execute updates, raw SQL or a stored procedure will always perform better than an ORM solution for bulk updates if you're changing enormous volumes of data.

2) Speed of Development

In most cases, EF will outperform raw SQL/stored procs in terms of development speed. In order to avoid synchronisation problems between your object code and your database code, the EF designer can (upon request) update your model from your database as it changes. The only situations in which I wouldn't think about utilizing an ORM are when you're building a reporting or dashboard application without doing any updating, or when you're building an application just to do database maintenance tasks on raw data.

3) Neat/Maintainable code

Hands down, EF beats SQL/sprocs. Because your relationships are modeled, joins in your code are relatively infrequent. The relationships of the entities are almost self-evident to the reader for most queries. Nothing is worse than having to go from tier to tier debugging or through multiple SQL/middle tier in order to understand what's actually happening to your data. EF brings your data model into your code in a very powerful way.

4) Flexibility

Stored procs and raw SQL are more "flexible". You can leverage sprocs and SQL to generate faster queries for the odd specific case, and you can leverage native DB functionality easier than you can with and ORM.

5) Overall

Avoid falling prey to the false choice between employing stored procedures or an ORM. Both can be used together in one application, and you should. Large-scale activities should be performed in stored procedures or SQL (which the EF can really call), but the majority of your middle-tier requirements should be met by EF. You might decide to write your reports using SQL. The lesson of the narrative is, I suppose, still the same as it always has been. Use the proper equipment for the task. But the short of it is that EF is excellent right now (as of .NET 4.0).

I hope this helps you.

answered Sep 16 by narikkadan
• 20,880 points

Related Questions In Database

0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
14,703 views
0 votes
1 answer

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
315 views
0 votes
1 answer

Function vs. Stored Procedure in SQL Server

Functions are calculated values that cannot make ...READ MORE

answered Feb 17 in Database by Neha
• 8,920 points

edited Feb 17 by Neha 460 views
0 votes
0 answers

How to display employee names starting with a and then b in sql

I want to display the names of ...READ MORE

Aug 12 in Database by Kithuzzz
• 12,240 points
46 views
0 votes
0 answers

Error converting data type nvarchar to datetime SQL Server

I encountered this error: Error converting data type ...READ MORE

Aug 15 in Database by Kithuzzz
• 12,240 points
297 views
0 votes
0 answers

How to Create a real one-to-one relationship in SQL Server?

I have two tables, Country and Capital, ...READ MORE

Aug 18 in Database by Kithuzzz
• 12,240 points
22 views
0 votes
1 answer
0 votes
1 answer

How interactive graphs are generated in Tableau?

Lot of back end code is shared ...READ MORE

answered Apr 14, 2018 in Tableau by xyz
• 1,560 points
250 views
0 votes
1 answer

Add a column with a default value to an existing table in SQL Server

Syntax: ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT ...READ MORE

answered Sep 12 in Database by narikkadan
• 20,880 points
63 views
0 votes
1 answer

How to add a Try/Catch to SQL Stored Procedure

See TRY...CATCH (Transact-SQL) CREATE PROCEDURE [dbo].[PL_GEN_PROVN_NO1] ...READ MORE

answered Sep 16 in Database by narikkadan
• 20,880 points
20 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP