5
Answers

opinion required @Entity framework

Photo of SUNIL GUTTA

SUNIL GUTTA

11y
825
1
Hi

Well there's been a discussion going around with my friends regarding usage of Stored procedures while using entity framework . .

I guess sp's will be useful what ever we use right . There been discussion i.e Entity framework provides efficient way to communicate to DB'S which makes SP'S no really needed like that .

So please anyone share there strong views and wipe my ignorance

Regards

Answers (5)

3
Photo of Vulpes
NA 98.3k 1.5m 11y
Well, for that matter, LINQ to SQL is based on ADO.NET as well!

I think there are several reasons why EF is becoming more popular than the other technologies.

1. As an 'object relational mapper' it is easier to use than 'raw' ADO.NET.

2. It is more strongly decoupled from the database than LINQ to SQL and is therefore more flexible.

3. Unlike LINQ to SQL, you are not just confined to SQL Server.

4. Microsoft are actively developng EF whereas development of LINQ to SQL seems to be relatively dormant.

Performance wise, I'd say EF is the slowest of the three as there's more overhead to overcome, though it's still quick enough for most purposes.

However, the other technologies still have their adherents:

1. If you're only interested in SQL Server and don't need to do anything too fancy, LINQ to SQL offers good performance and relatively simplicity.

2. If (like me) you used raw ADO.NET before the LINQ technologies were dreamed up and don't mind working directly with DataSets and SQL queries or creating your own class mappings, then raw ADO.NET offers the best performance and less 'head scratching' than the other two.


Accepted
15
Photo of Vulpes
NA 98.3k 1.5m 11y
Well, whether you're using raw ADO.NET, LINQ to SQL or EF, stored procedures have the same performance, productivity and scalability advantages as they've always had.

EF therefore needs a mechanism for calling existing Stored Procedures which, of course, it does have.

Moreover, whatever you do in EF is eventually going to be translated into native SQL when communicating with the database because that's all the database understands. So EF can never be more efficient that native SQL and does have its own overhead.

If therefore the database doesn't already have an SP to perform a certain operation but you can add one, then I think you should and then have EF call it. There will be no loss in efficiency and the SP will be available when manipulating the database directly.

However, if (for some reason) you can't add an SP to the database, then by all means use EF to generate code which does the same thing. 


10
Photo of Lakshmanan Sethu
NA 19.3k 2.4m 11y
Hi Sunil, I would like to clarify one thing. EF is actually built on ADO .NET to make our job easy.
0
Photo of SUNIL GUTTA
NA 1.1k 286.3k 11y
Yes you are right :) i too came to know that . so we can say about EF like just we are using to make the code less ?

Thank you .
0
Photo of SUNIL GUTTA
NA 1.1k 286.3k 11y
yeah thanks for clarifying things .Thank you

Well i need ur opinion on why entuty framework is being used by mostly these days where this ADO.NET looks cool and easy to implement things from my side .

Any syntactical advantages ? performance ? anything is specific makes EF special ?

Thank you so much mate