1

I was wondering if there is a way to leverage MVC (and the scaffolding features) and EF in a such a way where all creates, updates, deletes and searches are executed using views and SPs? The reason being is that based on certain changes there might be other DB actions that need to be performed, and for various reasons I would like that business logic to live in SPs.

Any advice would be greatly appreciated.

Thanks.

tereško
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

0

You really don't want your business logic to live in your SPs. The most obvious reason is that your rules will not be easily testable. Your best bet, IMHO is to follow the repository pattern and interact with your database via SPs and move your rules to another set of classes. You can then mock your data and have a nice suite of unit tests to ensure everything stays running smoothly after feature-adds and refactoring.

If all of your DB access is handled via SPs, using straight ADO instead of EF might also be preferable. You won't have to carry the extra weight that comes with EF and you should see some increased performance.

agartee
  • 445
  • 2
  • 15