Skip to content

4. Scaffold The Backend

codeplanner edited this page Dec 30, 2014 · 2 revisions

Generating all the layers

When you are happy with your domain model it is time to generate all the code for repositories and services. In our sample we only had the Person class, but you will probably have a lot more classes in your domain model in real-life... And the bigger the model the more time you save.

Scaffold

To get all files generated you open up the Package Manager Console and then type

PM> Scaffold Bob.ScaffoldBackend

This command will look for all classes that inherit the PersistentEntity class and generate

  • Repository Interface
  • Service Interface
  • Repository
  • Service
  • ViewModel

For each class in the model.

The output in the Package Manager Console will show something like this for each class

PM> Scaffold Bob.ScaffoldBackend
Collecting properties for the model, this might take a while
Added Repository at PersonRepository.cs
Added IRepository of Person output at Interfaces\Data\IPersonRepository.cs
Added Service at PersonService.cs
Added IService of Person output at Interfaces\Service\IPersonService.cs
Collecting properties for the model, this might take a while
Name,string Age,int
Added ViewModel for Person ViewModel\PersonViewModel.cs

The next step is to use setup IoC so that we can call our service for the first time and generate our database.

Clone this wiki locally