Muonroi.BaseTemplate 1.7.2

There is a newer version of this package available.
See the version list below for details.
dotnet new install Muonroi.BaseTemplate::1.7.2
                    
This package contains a .NET Template Package you can call from the shell/command line.

Muonroi.BaseTemplate

Ask DeepWiki

A .NET solution template for building ASP.NET Core applications using Clean/Onion Architecture with the Muonroi.BuildingBlock library.

Quick Start

# 1. Install template
dotnet new install Muonroi.BaseTemplate

# 2. Create new project
dotnet new mr-base-sln -n MyProject -C MyCore

# 3. Setup
cd MyProject
dotnet restore

# 4. Run migrations (optional)
./scripts/ef.sh add InitialCreate
./scripts/ef.sh update

# 5. Run
cd src/MyProject.API
dotnet run

Open: https://localhost:5001/swagger

Prerequisites

Installation

dotnet new install Muonroi.BaseTemplate

From source

git clone https://github.com/muonroi/MuonroiBuildingBlock.git
cd MuonroiBuildingBlock/src/Muonroi.Base.Template
dotnet new install ./

Verify installation

dotnet new list | grep "mr-base-sln"

Usage

Create new project

dotnet new mr-base-sln -n <ProjectName> [-C <ClassName>]
Parameter Short Description Default
--name -n Solution/project name (required)
--ClassName -C Base name for classes (DbContext, etc.) BaseTemplate

Examples

# Basic
dotnet new mr-base-sln -n MyApp

# With custom class name
dotnet new mr-base-sln -n TruyenTM -C TruyenTM
# Generates: TruyenTMDbContext, TruyenTMRepository, etc.

Project Structure

MyProject/
├── MyProject.sln
├── scripts/
│   └── ef.sh                    # Cross-platform migration helper
├── src/
│   ├── MyProject.API/           # Presentation Layer
│   │   ├── appsettings.json
│   │   ├── appsettings.Development.json
│   │   ├── appsettings.Production.json
│   │   ├── appsettings.Example.json   # Configuration reference
│   │   ├── Program.cs
│   │   ├── Controllers/
│   │   └── Application/
│   ├── MyProject.Core/          # Domain Layer
│   │   ├── Entities/
│   │   └── Interfaces/
│   └── MyProject.Data/          # Infrastructure Layer
│       ├── MyDbContext.cs
│       └── Repositories/
└── README.md

Configuration

Supported Database Types

DbType Connection String Key
Sqlite SqliteConnectionString
SqlServer SqlServerConnectionString
MySql MySqlConnectionString
PostgreSql PostgreSqlConnectionString
MongoDb MongoDbConnectionString

Example Configuration

{
  "DatabaseConfigs": {
    "DbType": "Sqlite",
    "ConnectionStrings": {
      "SqliteConnectionString": "Data Source=app.db"
    }
  },
  "TokenConfigs": {
    "Issuer": "https://localhost:5001",
    "Audience": "https://localhost:5001",
    "SigningKeys": "your-secret-key-minimum-32-characters!",
    "UseRsa": false,
    "ExpiryMinutes": 60
  },
  "EnableEncryption": false
}

See appsettings.Example.json for all available options with documentation.

Feature Flags

Toggle optional features to reduce startup time:

{
  "FeatureFlags": {
    "UseGrpc": false,
    "UseServiceDiscovery": false,
    "UseMessageBus": false,
    "UseBackgroundJobs": false,
    "UseEnsureCreatedFallback": true
  }
}

Database Migrations

Linux/macOS (or Git Bash on Windows):

./scripts/ef.sh add InitialCreate
./scripts/ef.sh update
./scripts/ef.sh list
./scripts/ef.sh help

Windows Command Prompt/PowerShell:

scripts\ef add InitialCreate
scripts\ef update
scripts\ef list
scripts\ef help

Using dotnet ef directly

dotnet ef migrations add "InitialCreate" \
    -p ./src/MyProject.Data \
    --startup-project ./src/MyProject.API \
    -o Persistence/Migrations

dotnet ef database update \
    -p ./src/MyProject.Data \
    --startup-project ./src/MyProject.API

Features

  • Clean Architecture - Separate layers: API, Core, Data
  • CQRS with MediatR - Command/Query separation
  • Authentication & Authorization - JWT, permissions, roles
  • Entity Framework Core - Multiple database support
  • Structured Logging - Serilog with Console/Elasticsearch
  • Caching - Memory, Redis, or Multi-level
  • Multi-tenancy - Data isolation by tenant
  • Service Discovery - Consul integration
  • Message Bus - Kafka/RabbitMQ via MassTransit
  • Background Jobs - Hangfire/Quartz

Documentation

Troubleshooting

"Connection string is not provided"

Ensure DbType matches the connection string key:

{
  "DatabaseConfigs": {
    "DbType": "MySql",  // Must match key below
    "ConnectionStrings": {
      "MySqlConnectionString": "..."  // ✓ Correct key
    }
  }
}

"The input is not a valid Base-64 string"

Set "EnableEncryption": false in appsettings.

API slow on startup

Disable unused features in FeatureFlags.

License

MIT License. See LICENSE.txt for details.

  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.9.3 100 2/8/2026
1.9.2 103 2/8/2026
1.8.1 109 1/25/2026
1.8.0 109 1/25/2026
1.7.6 107 1/24/2026
1.7.5 104 1/24/2026
1.7.4 104 1/24/2026
1.7.3 112 1/24/2026
1.7.2 126 1/15/2026
1.7.0 135 1/11/2026
1.6.24 140 1/10/2026
1.6.23 139 1/4/2026
1.6.20 135 1/2/2026
1.6.19 136 1/2/2026
1.6.16 138 1/1/2026
1.6.15 132 1/1/2026
1.6.14 144 12/29/2025
1.6.13 139 12/29/2025
1.6.12 132 12/29/2025
1.6.11 137 12/29/2025
Loading failed