NetSchema 3.0.3

dotnet tool install --global NetSchema --version 3.0.3
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local NetSchema --version 3.0.3
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=NetSchema&version=3.0.3
                    
nuke :add-package NetSchema --version 3.0.3
                    

NetSchema - N-Tier Architecture Generator

NuGet Downloads License

Complete N-Tier architecture generator for .NET 8 ??
One command to generate Core, DAL, Business, API, and Shared layers with Repository Pattern, AutoMapper, FluentValidation, and sample CRUD operations.

?? Features

? 5-Layer Architecture - Core, DAL, Business, API, Shared
? Repository Pattern - Generic CRUD with soft delete
? AutoMapper - Automatic DTO mappings
? FluentValidation - Request validation
? Sample CRUD - Working controller with Swagger
? Dependency Injection - Pre-configured DI
? EF Core - DbContext with query filters

?? Installation

dotnet tool install --global NetSchema

Update Existing

dotnet tool update --global NetSchema

?? Quick Start

1. Create a new solution

mkdir MyAwesomeApp
cd MyAwesomeApp
dotnet new sln -n MyApp

2. Generate N-Tier architecture

dotnet netschema generate

That's it! ??

?? Generated Structure

MyAwesomeApp/
??? MyApp.sln
??? App.Core/              # Domain Layer
?   ??? Entities/
?   ?   ??? BaseEntity.cs
?   ?   ??? IAuditedEntity.cs
?   ?   ??? SampleEntity.cs
?   ??? Enums/
?   ?   ??? SampleEnum.cs
?   ??? Exceptions/
?
??? App.DAL/               # Data Access Layer
?   ??? Persistence/
?   ?   ??? AppDbContext.cs
?   ??? Repositories/
?   ?   ??? Interfaces/
?   ?   ?   ??? IRepository.cs
?   ?   ??? Implementations/
?   ?       ??? Repository.cs
?   ??? Handlers/
?   ??? Migrations/
?   ??? DALDependencyInjection.cs
?
??? App.Business/          # Business Logic Layer
?   ??? DTOs/
?   ?   ??? SampleEntityDto.cs
?   ??? Validators/
?   ?   ??? SampleEntityValidator.cs
?   ??? MappingProfiles/
?   ?   ??? MappingProfile.cs
?   ??? Services/
?   ??? Helpers/
?   ??? BusinessDependencyInjection.cs
?
??? App.API/               # Presentation Layer
?   ??? Controllers/
?   ?   ??? SampleController.cs
?   ??? Program.cs
?   ??? appsettings.json
?   ??? appsettings.Development.json
?
??? App.Shared/            # Shared Utilities
    ??? Implementations/
    ??? Interfaces/

?? Configuration

1. Update Connection String

Edit App.API/appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=MyAppDb;User Id=sa;Password=YourPassword123;TrustServerCertificate=True"
  }
}

2. Create & Apply Migrations

cd App.API
dotnet ef migrations add InitialCreate
dotnet ef database update

3. Run the API

dotnet run

Open Swagger: https://localhost:5001/swagger

?? Example Usage

Generated Sample Controller

The generated SampleController includes:

  • ? GET /api/sample - Get all entities
  • ? GET /api/sample/{id} - Get by ID
  • ? POST /api/sample - Create new
  • ? PUT /api/sample/{id} - Update existing
  • ? DELETE /api/sample/{id} - Soft delete

Sample Request (POST)

POST /api/sample
{
  "name": "John Doe",
  "description": "Sample description"
}

Sample Response

{
  "id": 1,
  "name": "John Doe",
  "description": "Sample description",
  "createdDate": "2025-01-30T00:00:00Z"
}

?? Customization

Add Your Own Entities

  1. Create entity in App.Core/Entities/:
public class User : BaseEntity, IAuditedEntity
{
    public string FullName { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;
    public DateTime CreatedDate { get; set; }
    public DateTime? UpdatedDate { get; set; }
    public bool IsDeleted { get; set; }
}
  1. Add DbSet to AppDbContext:
public DbSet<User> Users { get; set; }
  1. Create migration:
dotnet ef migrations add AddUserEntity
dotnet ef database update

?? Advanced Features

Repository Pattern

// Inject in your service
private readonly IRepository<User> _userRepository;

// CRUD operations
var users = await _userRepository.GetAllAsync();
var user = await _userRepository.GetByIdAsync(x => x.Id == userId);
await _userRepository.AddAsync(newUser);
await _userRepository.UpdateAsync(user);
await _userRepository.DeleteAsync(user); // Soft delete
await _userRepository.RemoveAsync(user); // Hard delete

AutoMapper

// In MappingProfile.cs
CreateMap<User, UserDto>();
CreateMap<CreateUserDto, User>();

FluentValidation

// In Validators/CreateUserValidator.cs
public class CreateUserValidator : AbstractValidator<CreateUserDto>
{
    public CreateUserValidator()
    {
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
        RuleFor(x => x.FullName).NotEmpty().MaximumLength(200);
    }
}

??? Architecture Overview

???????????????????????????????????????????????
?           App.API (Presentation)            ?
?  Controllers, Swagger, Program.cs           ?
???????????????????????????????????????????????
                   ?
???????????????????????????????????????????????
?       App.Business (Business Logic)         ?
?  Services, DTOs, Validators, Mappings       ?
???????????????????????????????????????????????
                   ?
???????????????????????????????????????????????
?         App.DAL (Data Access)               ?
?  DbContext, Repositories, Migrations        ?
???????????????????????????????????????????????
                   ?
???????????????????????????????????????????????
?         App.Core (Domain)                   ?
?  Entities, Interfaces, Enums                ?
???????????????????????????????????????????????

?? Package Versions

  • EF Core: 8.0.0
  • AutoMapper: 12.0.1
  • FluentValidation: 11.9.0
  • Swashbuckle: 6.5.0

?? Troubleshooting

Tool not found

dotnet tool uninstall --global NetSchema
dotnet tool install --global NetSchema

Solution not found

Make sure you're in a directory with a .sln file, or create one:

dotnet new sln -n MyApp

Migrations error

cd App.API
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet ef migrations add InitialCreate

?? Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

?? License

This project is licensed under the MIT License - see the LICENSE file for details.

????? Author

Emil Huseyn
GitHub: @emilhuseyn

?? Star History

If you like this project, please give it a ? on GitHub!

?? Resources

?? Learn More


<div align="center"> Made with ?? by <a href="https://github.com/emilhuseyn">Emil Huseyn</a> </div>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
3.0.3 186 11/4/2025
3.0.2 173 11/4/2025
3.0.1 188 10/29/2025
3.0.0 163 10/29/2025
1.0.0 175 4/22/2025

Version 3.0.3 - Documentation Update: Enhanced README with complete usage guide, step-by-step quick start instructions, architecture diagrams and examples, troubleshooting section added, better customization examples, complete API endpoint documentation, migration and configuration guides. Features: One command to generate 5-layer architecture, Repository Pattern with soft delete, AutoMapper and FluentValidation integration, Sample CRUD controller with Swagger, Dependency Injection pre-configured. Quick Start: 1. dotnet tool install --global NetSchema 2. mkdir MyApp and cd MyApp 3. dotnet new sln -n MyApp 4. dotnet netschema generate. GitHub: https://github.com/emilhuseyn/NetSchema