By the end of this guide you will have a fully working ASP.NET Core Web API that stores aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Orbis25/FoundationKit/llms.txt
Use this file to discover all available pages before exploring further.
Person entity in a PostgreSQL database, exposes standard CRUD endpoints through FoundationKit’s base controller, and returns paginated results from a single GET request — all without writing a single line of query or routing logic yourself.
Install the NuGet packages
Add all four FoundationKit packages to your ASP.NET Core project. The umbrella
FoundationKit package already depends on the other three, but installing them explicitly lets you control versions independently.Define your entity model
Create a class that inherits
BaseModel. You get Id (Guid), CreatedAt, UpdatedAt, IsDeleted, CreatedBy, and UpdatedBy for free. Add only the properties specific to your domain.BaseModel exposes the following members automatically:| Property | Type | Notes |
|---|---|---|
Id | Guid | Primary key |
CreatedAt | DateTime | Set on insert |
UpdatedAt | DateTime? | Set on update; override and add [Column] to persist |
IsDeleted | bool | Used by SoftRemoveAsync |
CreatedBy | string? | Optional auditing field |
UpdatedBy | string? | Optional auditing field |
Create your DbContext
Inherit from Register the context in Then run the EF Core tooling to create your first migration:
FoundationKitDbContext and add a DbSet<T> for each entity. Then register the context in Program.cs using your preferred provider (the example project uses PostgreSQL via Npgsql).Program.cs:Create a repository (service) class
Inherit Then implement it:You can override any method in
BaseRepository<TContext, TModel> to get the full IBaseRepository<TModel> implementation — CreateAsync, UpdateAsync, GetByIdAsync, GetPaginatedListAsync, SoftRemoveAsync, and more — with transactional commit handling included.First declare the interface:BaseRepository to add custom query logic. The GetAll method returns an IQueryable<TModel> that you can further compose before materialising.Register services with AddFoundationKit
Wire everything up in If you also want the RSA/AES encryption service available across your application, chain
Program.cs. AddFoundationKit scans your assembly for AutoMapper profiles and registers the mapping infrastructure. Add your scoped service registration alongside it.AddFoundationKit calls services.AddAutoMapper(assembly) internally. If you are using MapRepository you must have at least one AutoMapper Profile class in the scanned assembly, otherwise AutoMapper will throw at startup.AddFoundationKitEncryptor:Create a controller
Inherit That is the entire controller. The following endpoints are now available:
Override any virtual action method on the controller to add custom behaviour, authorization attributes, or response shaping.
ApiCoreController<TModel, TService>. The base class maps the route as api/[controller] and generates five endpoints automatically: GET (paginated list), GET {id}, POST, PUT {id}, and DELETE {id} (soft delete).| Method | Route | Description |
|---|---|---|
GET | /api/people?page=1&qyt=10 | Paginated list |
GET | /api/people/{id} | Single entity by GUID |
POST | /api/people | Create entity |
PUT | /api/people/{id} | Full update |
DELETE | /api/people/{id} | Soft delete (IsDeleted = true) |
Next Steps
- Read the Packages reference to understand what each NuGet package provides and when to install only a subset.
- Use
AddFoundationKitIdentityWithMapper<TUser, TDbContext>if your project needs ASP.NET Core Identity baked in alongside AutoMapper. - Explore
ApiMapControllerwhen you want strict separation between input DTOs, edit DTOs, and output DTOs with AutoMapper-powered mapping at the repository layer.