A production-ready N-Tier Architecture solution template for building clean, modular, scalable ASP.NET Core Web API applications with Entity Framework Core and JWT Authentication.
- API: ASP.NET Core Web API layer (Controllers, Middleware)
- Core: Domain entities, DTOs, Interfaces
- Repository: EF Core, DbContext, Repository implementations
- Service: Business logic, Service implementations
Each layer is cleanly separated and connected via Dependency Injection.
Install the required templates and CLI tool in one command:
dotnet new install FSipka.ModelTemplates::1.0.0;
dotnet new install FSipka.Templates::1.0.0;
dotnet tool install --global FSipka.CLI --version 1.1.3;
To scaffold a new N-Tier project, use:
fsipka create-new -n MyProjectName
This creates a solution with:
MyProject.API
MyProject.Core
MyProject.Repository
MyProject.Service
Everything is pre-configured for dependency injection, JWT auth, EF Core, and more.
To generate a full entity including all layers:
fsipka add-model -n Product
This creates:
- Entity class in
Core/Entities
- DTOs in
Core/DTOs
- Interfaces in
Core/Interfaces
- Service logic in
Service
- Repository access in
Repository
- Controller in
API
- AutoMapper mapping
- FluentValidation validator (if needed)
/src
/MyProject.API → Web API (controllers, auth, middleware)
/MyProject.Core → Entities, DTOs, interfaces
/MyProject.Repository → DbContext, EF Core configs, Repositories
/MyProject.Service → Business logic, application services
/tests
/MyProject.Tests → Unit/integration tests (xUnit)
The Repository
project includes pre-configured support for EF Core.
After generating your project or adding a model, you must create and apply a migration to update the database schema.
cd src/MyProject.Repository
dotnet ef migrations add InitialCreate
dotnet ef database update
You must have the
dotnet-ef
tool installed:
dotnet tool install --global dotnet-ef
Also make sure the connection string is correctly set in
appsettings.Development.json
.
JWT-based authentication is already integrated.
You only need to configure your settings in appsettings.json
:
"Jwt": {
"Key": "YourSuperSecretKeyHere",
"Issuer": "MyApp",
"Audience": "MyAppUsers",
"ExpiresInMinutes": 60
}
The solution includes a test project using xUnit, with support for mocking services and dependency injection.
Package | Purpose |
---|---|
FSipka.Templates |
Project scaffolding templates |
FSipka.ModelTemplates |
Model scaffolding templates |
FSipka.CLI |
CLI to create project/models |
Microsoft.EntityFrameworkCore |
ORM layer (EF Core) |
AutoMapper |
Object mapping |
FluentValidation |
Model validation |
Swashbuckle.AspNetCore |
Swagger/OpenAPI docs |
Task | Command |
---|---|
Create new project | fsipka create-new -n ProjectName |
Add a new entity model | fsipka add-model -n Product |
Add EF Core migration | dotnet ef migrations add InitialCreate |
Apply EF Core migration | dotnet ef database update |
Created and maintained by Fatih Sipka
Contact: [email protected]
This project is open-source and available under the MIT License.