A robust .NET 8.0 solution template for building modern, scalable API projects with Entity Framework Core and MySQL/MariaDB support.
This project is designed as a starting point for ASP.NET API development, providing a clean architecture, reusable base controllers, repository patterns, and ready-to-extend infrastructure for real-world applications.
- Multi-project solution: Separation of concerns with
API_Template(API),App(application logic), andData(data access) - Entity Framework Core: Pre-configured for both SQL Server and MySQL/MariaDB (Pomelo)
- Repository & Specification Pattern: Generic repositories and specifications for flexible, testable data access
- Base Controllers:
BaseApiControllerfor CRUD and paginationBaseMappingApiControllerfor DTO mapping and advanced result shaping using AutoMapper
- AutoMapper Integration: Simplifies mapping between entities and DTOs
- Middleware & Helpers: Easily extendable for authentication, error handling, logging, and more
- Mocked ExampleDbContext: Demonstrates entity relationships and configuration without requiring a real database
- Ready for Code-First or Database-First: Scaffold or design your models as needed
- BaseApiController: Provides generic CRUD, pagination, and utility endpoints for any entity via repository pattern.
- BaseMappingApiController: Extends the base controller with AutoMapper-powered endpoints for DTO mapping and paged results.
public class BaseMappingApiController(IMapper mapper) : BaseApiController
{
protected readonly IMapper _mapper = mapper;
// AddEntity, CreateMappedPagedResult, GetMappedEntityWithSpec, etc.
}API_Template/Controllers/Base/— Base controllers for rapid API developmentApp/Helpers/— Utility classes and helpers for specifications, pagination, etc.App/Spec/— Specification pattern for flexible queriesData/Interfaces/— Generic repository interfacesData/Entities/DatabaseDB/— ExampleDbContext and mock entities
- Clone the repository
- Open in Visual Studio 2022+
- Restore NuGet packages
- Update connection strings as needed in your DbContext
- Add your own entities, DTOs, and business logic
- Extend controllers, repositories, and middleware to fit your requirements
- Add new controllers by inheriting from
BaseApiControllerorBaseMappingApiController - Define new entities and DTOs in the
DataandAppprojects - Register new repositories and services in the DI container
- Add or customize middleware for authentication, error handling, etc.
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Tools
- Pomelo.EntityFrameworkCore.MySql
- MySql.EntityFrameworkCore
- AutoMapper
See LICENSE.txt for details.