RT88
RT88

Reputation: 669

Stored Procedures and the Entity Framework

Entity Framework or stored procedures / functions

  1. Which is better?
  2. In which scenarios would using stored procedures or Entity Framework be better?
  3. Is the performance of one technology better than the other?

I have used both methods to retrieve and manipulate data and don't really have a preference. I think stored procedures / function allows us a clearer separation of concerns. But using C# to develop functionality to query and manipulate data does seem more easy.

Upvotes: 0

Views: 254

Answers (1)

Tiago Gouvêa
Tiago Gouvêa

Reputation: 16730

  1. Which is better?

    • If stored procedure return big data results and/or your connection as slow > EF
    • If you REALLY like SQL and have read a little about use of CURSORS, and staying liking it > SP
  2. In which scenarios would using stored procedures or Entity Framework be better?

    • If you need do complex codes in a small time > EF
    • If you need process biiiig data on database, reviewing records, doing batch updates, using triggers > SP
  3. Is the performance of one technology better than the other?

    • You you get 1000 records in EF, you will have 1000 objects in memory, but, how you work with your code is the main focus here. I did some big data update using SP and it's really so much fast, because it ON database, no TCP involved, no socket, no traffic.. just read/update. But, you will lost so much time to write good SQL codes...

Another thing to think. If you use EF, you must prefere to have all you bussines logic in one place, using partial classes or extensions.. you will don't to have so much logic on yout database.

Upvotes: 1

Related Questions