CleanArchitecture screenshot

CleanArchitecture

Author Avatar Theme by Jasontaylordev
Updated: 10 Nov 2025
19535 Stars

Clean Architecture Solution Template for ASP.NET Core

Categories

Overview

The Clean Architecture Solution Template is designed to simplify enterprise application development by leveraging Clean Architecture and ASP.NET Core. It allows developers to easily create a Single Page App (SPA) using Angular and ASP.NET Core while following the principles of Clean Architecture. The template utilizes technologies such as ASP.NET Core, Entity Framework Core, Angular, MediatR, AutoMapper, FluentValidation, and testing frameworks like NUnit, FluentAssertions, Moq, and Respawn. To get started, developers can install the .NET template and run specific commands.

Features

  • Clean Architecture: Promotes separation of concerns and maintainability by implementing a modular and layered architecture.
  • Angular Integration: Allows the creation of SPAs using Angular with ASP.NET Core.
  • Use of Entity Framework Core: Provides a powerful and flexible ORM for database interactions.
  • MediatR: Enables the implementation of the Mediator design pattern for decoupling message senders and receivers.
  • AutoMapper: Simplifies the mapping of objects between layers of the application.
  • FluentValidation: Offers an intuitive and fluent way to define validation rules.
  • Testing Frameworks: Includes NUnit, FluentAssertions, Moq, and Respawn for unit testing and mocking.

Installation

To install the Clean Architecture Solution Template, follow these steps:

  1. Make sure you have the latest versions of .NET 8 SDK and Node.js LTS installed.
  2. Run the command dotnet new install Clean.Architecture.Solution.Template to install the .NET template.
  3. Create a new project by running dotnet new ca-sln --output YourProjectName.
  4. Navigate to the YourProjectName/src/WebUI directory.
  5. Launch the project using the command dotnet run.

For database configuration:

  • By default, the template uses an in-memory database to ensure easy setup. No additional infrastructure, like SQL Server, is required.
  • To use SQL Server, update the connection string in WebUI/appsettings.json to point to a valid SQL Server instance.
  • When running the application, the database will be automatically created (if necessary) and the latest migrations will be applied.

To perform database migrations with dotnet-ef, follow these steps:

  1. Disable the “UseInMemoryDatabase” setting in the previous section.
  2. Add the following flags to your command (values assume you are executing from the repository root):
    • --project src/Infrastructure (optional if in this folder)
    • --startup-project src/WebUI
    • --output-dir Persistence/Migrations
  3. For example, to add a new migration from the root folder: dotnet ef migrations add "SampleMigration" --project src/Infrastructure --startup-project src/WebUI --output-dir Persistence\Migrations

Summary

The Clean Architecture Solution Template provides developers with a streamlined approach to enterprise application development using Clean Architecture and ASP.NET Core. It offers features such as Angular integration, Entity Framework Core, MediatR, AutoMapper, FluentValidation, and testing frameworks. By following the installation guide, developers can quickly set up the template and start building their applications. Overall, the template promotes maintainability, separation of concerns, and flexibility in application development.