Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there!!!

I am implementing a project where I am using Entity Framework as Data Access Layer.
I have implemented several stored procedures for doing CRUD operations on database in Sql Server; Now I want to use those stored procedures with Entity Framework for doing CRUD operations from my application, So is it good to use Stored Procedures with Entity Framework and Is there any benefit if I am using Stored Procedures with Entity Framework?

Thanks!!!!!
Posted
Updated 25-Aug-15 2:37am
v2

You can use SPs if you want, but you're pretty much defeating the object of using Entity Framework at all. The only real advantage you'll gain is when creating data from the SPs Entity Framework will give you specific classes back with the data already populated rather than you having to read the raw data from an SP like you would with ADO.net.
 
Share this answer
 
Entity framework is ultimately an ORM which facilitates the developer who doesn't know how to write good SQL queries but obviously that facility comes at some cost in terms of performance.

Stored procedures are pre-compiled while EF will generate query every time.
Furthermore the SP based application is more maintainable i.e. suppose you've deployed the project at production server and now you realize that you've to change some computation or data retrieval logic, you can simply connect to live db and change respective stored procedures but in other case (using EF & LINQ entirely) you'll have to make changes in your application code and then re-deploy the code!

So if you are good at writing queries then go ahead with stored procedures. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900