Quick start
This page walks you through the creation of your first generated solution using the Scaffolder.net application.
You define your domain models through a step-by-step User Interface, and the Generator will create all the source files for a fully functional application.
From a blank workspace to a downloadable project, it should take only a few minutes.
Prerequisites
Step 1 : Create a Solution
A Solution represents the root container for your application. It holds all the Bounded contexts, Entities, and Entity properties needed to generate a complete application.
Follow these steps to create your first Solution :- Click the "Solutions" section from the main menu
- Click the "Add" button
- Enter a Name using PascalCase format (For example "MyShop")
- Click the "Create" button
- The solution is created and appears in the list
- The solution Name becomes the root namespace and the name of the .slnx file (for example "MyShop" generates "MyShop.slnx" and namespaces will start with "MyShop.")
For a full overview of the Solutions User Interface, see the /Documentation/UserInterface/Solutions page.
Step 2 : Create a Bounded context
A Bounded Context represents a set of Domain, Application, Persistence and Presentation(s) projects. You can have one or more Bounded contexts within a solution, each focusing on a distinct area of the application.
Follow these steps to create your first Bounded context :- Click the "Eye" button (Details) from the "Solutions" List on the left of your newly created Solution
- Click the "Add" button under the "Bounded contexts" List
- Enter a Name using PascalCase format (For example "Catalog")
- Click on the presentation project type(s) you want to generate (For example "Generate Blazor Server presentation")
- Click the "Create" button
- The Bounded context is created and appears in the list
- The Bounded context Name becomes the suffix namespace for its projects (for example "Catalog" generates "MyShop.Domain.Catalog", "MyShop.Application.Catalog", etc.)
For a full overview of the Bounded contexts User Interface, see the /Documentation/UserInterface/BoundedContexts page.
Step 3 : Create an Entity
An Entity represents a core business object within a Bounded context. It encapsulates the data and behavior related to a specific concept in your domain.
Follow these steps to create your first Entity :- Click the "Eye" button (Details) from the "Bounded contexts" List on the left of your newly created Bounded context
- Click the "Add" button under the "Entities" List
- Enter a singular and its plural Name using PascalCase format (For example "Product" and "Products")
- Leave all other settings as they are for now
- Click the "Create" button
- The Entity is created and appears in the list
- The Entity singular Name becomes the class name and the plural Name becomes the DbSet name (for example "Product" generates a "ProductEntity" class and a "Products" DbSet)
For a full overview of the Entities User Interface, see the /Documentation/UserInterface/Entities page.
Step 4 : Create a Property for the Entity
An Entity property represents a specific property (field) of an entity. It defines the data type, constraints, and behavior associated with that property.
Follow these steps to create your first Entity property :- Click the "Eye" button (Details) from the "Entities" List on the left of your newly created Entity
- Click the "Add" button under the "Entity properties" List
- Enter a Name using PascalCase format (For example "Name")
- Leave all other settings as they are for now
- Click the "Create" button
- The Entity property is created and appears in the list
- The Entity property Name becomes the name of the field (for example "Name" generates a "public string Name { get; private set; } = null!;" property)
For a full overview of the Entity properties User Interface, see the /Documentation/UserInterface/EntityProperties page.
Step 5 : Download the Solution
- Once your model is complete, go back to the Solution details page by navigating through the breadcrumbs links at the top of the page
- You can preview the generated files tree and content by clicking on the "View Files" button
- Click on the "Download Solution" button to download a Zip file containing the generated Solution
- Extract the downloaded Zip file to a desired location on your computer
- Open the ".slnx" file at the root of the extracted folder in your preferred IDE to open the Solution
Step 6 : Configure Database
Connection String Configuration
To configure the database, you must first configure a Connection String using one of these two options.
Option 1 : Using a appsettings.json file
This option is not recommended because the Connection String will be stored in source control, but it is the easiest way to get started.- Add a appsettings.json file at the root of your Infrastructure.Persistence project
- Configure the Connection String in the appsettings.json file depending on your Solution Name, Bounded context Name and your Database setup, for example :
{
"ConnectionStrings":
{
"{{Solution.Name}}{{BoundedContext.Name}}DbConnectionString": "Server=localhost\\SQLEXPRESS;Database={{Solution.Name}}{{BoundedContext.Name}}Db;Trusted_Connection=True;TrustServerCertificate=True;"
}
}
Option 2 : Using an Environment Variable
This option is recommended for production environments because the Connection String is not stored in source control.- Create an environment variable depending on your Solution Name, Bounded context Name and your Database setup, for example :
Variable Name : ConnectionStrings__{{Solution.Name}}{{BoundedContext.Name}}DbConnectionString
Variable Value : Server=localhost\\SQLEXPRESS;Database={{Solution.Name}}{{BoundedContext.Name}}Db;Trusted_Connection=True;TrustServerCertificate=True;
Database Migration and Update
Once the Connection String is configured, you can run the database migration and update using your IDE terminal.
A DesignTimeDbContextFactory class is used to create instances of your DbContext at design time, which is required for migrations and updates.
Run the following commands in your IDE terminal to apply the migrations and update the database :
# 1. Navigate to the Infrastructure.persistence project folder depending on your Solution location path, Solution Name and Bounded context Name, for example :
cd C:\Development\{{Solution.Name}}\Sources\{{Solution.Name}}.Infrastructure.Persistence.{{BoundedContext.Name}}
# 2. Run the migration command depending on your Solution Name and Bounded context Name, for example :
dotnet ef migrations add InitialCreate --context {{Solution.Name}}{{BoundedContext.Name}}DbContext
# 3. Run the update command depending on your Solution Name and Bounded context Name, for example :
dotnet ef database update --context {{Solution.Name}}{{BoundedContext.Name}}DbContext
If no error occur, the database has been successfully created and updated.
Step 7 : Run the Solution
Once the database is created and updated, you can run the solution by setting the Presentation project as the startup project and execute the Solution to see it in action.
Have fun exploring your new application !
Next Steps
- Review the Architecture Documentation to understand the generated structure
- Review the Layers Documentation to understand how each layer interacts
- Review the Presentations Documentation to understand the UI components
- Review the Shared Documentation to understand the shared resources and utilities
- Review the User Interface Documentation to understand all the possibilities that offers Scaffolder.net
- Add / Edit / Delete Solutions, Bounded Contexts, Entities and their properties and Download the next version of your application
- Customize the generated code for your specific business needs