The goal of this template is to provide a straightforward and efficient approach to enterprise application development, leveraging the power of Clean Architecture and ASP.NET Core. Using this template, you can effortlessly create a WebApi, while adhering to the principles of Clean Architecture. Getting started is easy - simply install the .NET template ( see below for full details).
If you find this project useful, please give it a star. Thanks! ⭐
The easiest way to get started is to install the .NET template:
dotnet new install Sebastien.Charton.Clean.Architecture.Solution.Template::1.5.0
To create a ASP.NET Core Web API-only solution:
dotnet new ca-sln -o YourProjectName --use-postgresql
Launch the app:
cd src/Web
dotnet run
To learn more, run the following command:
dotnet new ca-sln --help
You can create use cases (commands or queries) by navigating to ./src/Application
and running dotnet new ca-usecase
.
Here are some examples:
To create a new command:
dotnet new ca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int
To create a query:
dotnet new ca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm
To learn more, run the following command:
dotnet new ca-usecase --help
The template is configured to use SQL Server by default. If you would prefer to use SQLite, create your solution using the following command:
dotnet new ca-sln --use-sqlite
When you run the application the database will be automatically created (if necessary) and the latest migrations will be applied.
Running database migrations is easy. Ensure you add the following flags to your command (values assume you are executing from repository root)
--project src/Infrastructure
(optional if in this folder)--startup-project src/Web
--output-dir Data/Migrations
For example, to add a new migration from the root folder:
dotnet ef migrations add "SampleMigration" --project src\Infrastructure --startup-project src\Web --output-dir Data\Migrations
The template includes a full CI/CD pipeline. The pipeline is responsible for building, testing, publishing and deploying the solution to Azure. If you would like to learn more, read the deployment instructions.
- ASP.NET Core 8
- Entity Framework Core 8
- MediatR
- AutoMapper
- FluentValidation
- XUnit, FluentAssertions, Moq & Respawn
The main branch is now on .NET 8.0. The following previous versions are available:
- Clean Architecture with ASP.NET Core 3.0 (GOTO 2019)
- Clean Architecture with .NET Core: Getting Started
If you are having problems, please let me know by raising a new issue.
This project is licensed with the MIT license.