A small but opinionated Vertical Slice Architecture solution template for .NET 8
To install the template from NuGet.org run the following command:
dotnet new install Hona.VerticalSliceArchitecture.TemplateThen create a new solution:
mkdir Sprout
cd Sprout
dotnet new hona-vsaFinally, to update the template to the latest version run:
dotnet new updateTo speed up development there is a dotnet new template to create a full Vertical Slice.
dotnet new hona-vsa-slice -f Student-f or --feature where the feature name is the singular name of the feature.
Of course, there are always exceptions where appending an 's' is not enough. For example, Person becomes People and Child becomes Children.
For this, use the optional parameter:
dotnet new hona-vsa-slice -f Person -fp Peopleoptional: -fp or --feature-plural where the feature name is the plural name of the feature.
This creates everything you need to get started with a new feature.
- Full CRUD endpoints
- CQRS
- missing
EventHandlers/folder as this is more uncommon - provides
Events/as a folder to demonstrate how to trigger side effects
- missing
- Basic REPR pattern (i.e., Request, an Endpoint, and a Response)
- Adds a new Entity
- Basic DDD pattern - the 'Complete' method on the entity shows adding Domain events and using
Resultobjects instead of exceptions for validation - Adds a DbSet to the DbContext
- Adds EF Core Entity Type Configuration
- Adds a Repository
While there is a small amount of code to remove, it is better to push you towards the pit of success, than allow inconsistency.
graph TD;
subgraph ASP.NET Core Web App
subgraph Slices
A[Feature A]
B[Feature B]
end
Slices --> |depends on| Common
Kernel --> |depends on| Common
Kernel --> |depends on| Slices
ASPNETCore[ASP.NET Core] --> |uses| Kernel
end
Common[Common]
- C# 12
- .NET 8
- ASP.NET Core
- Minimal APIs
- EF Core
- Swagger UI
