I disagree with both of the existing answers here. Petapoco is great, but I think that EF still offers a number of advantages.
Petapoco works great (maybe even better than EF) for executing simple stored procedures that read a single object or list of entities. However, as soon as you read the data and begin to modify it, I feel that EF is a clear winner.
To insert / update data using petapoco, you need to manually call the stored procedure insert / update using:
db.Execute("EXEC spName @param1 = 1, @param2 = 2")
Manually building a stored procedure call and declaring all parameters gets old very quickly when the insert / update stored procedures insert rows with several pairs of columns. This gets even worse when invoking updated stored procedures that implement optimistic concurrency (i.e., pass initial values โโas parameters).
In addition, you run the risk of making a typo in your call to the stored procedure, which most likely will not be detected before execution.
Now compare this to an entity framework: in EF, I would just bind my stored procedure to my entity in edmx. There is less risk of typos because the entity infrastructure tools automatically generate a mapping by analyzing my stored procedure.
The essence of the framework will also cope with optimistic concurrency without any problems. Finally, when it comes time to save changes, the only challenge is to call:
entities.SaveChanges()
source share