Search code examples
asp.net-mvct4asp.net-mvc-scaffolding

MvcScaffolding for a Services/Repository pattern?


Does anybody know of any examples of an MvcScaffolding T4 template for building Services/Repository pattern?

I know that MvcScaffolding comes with a Repository scaffold built in, but I'd like to have it also build a Services layer at the same time. I've spent an hour or so looking around but haven't seen what I'm looking for.

Suggestions? Thanks!


Solution

  • The service layer is something specific to your domain, not your database. It is something that an automated tool cannot create because the service layer doesn't only depend on the database. It might depend on many other external factors. The service layer is something that you should build yourself and then you could reference the repositories that were created for you in this service layer.

    But the main question you need to ask yourself is whether you need a service layer. Whether you have some complex business operations that are not simple CRUD operations with your data entities and which are handled directly by the repositories.