Skip to content

3. Add The Domain Model

codeplanner edited this page Jan 1, 2015 · 3 revisions

Prepare for your first scaffolding

Before you can scaffold any code you need to add a domain model. The domain model will be the foundation for your database, your data layer and your service layer.

There is no magic in this, just use Entity Framework Code First as usual to create your POCO´s, but.... In SpongeBob all your classes in the domain model will have to inherit the PersistentEntity class. The class added will have to be placed in the *.Core project in the root of the folder Model

Adding a Person class to the model

You can add it manually, but you can also use the scaffolder in the Package Manager Console

PM> Scaffold Bob.AddClass Person

That command will add a new file/class in the root of the Model folder in the *.Core project that looks like this

using System;

namespace MyWebApp.Core.Model
{
    public class Person : PersistentEntity
    {
        //TODO: Add your properties here
    }
}

Now you just have to populate your class with some properties, for example Name, Age and other things that your person might have.

Next step scaffold the backend

Clone this wiki locally