Every entity in a FoundationKit application starts from one of two abstract base classes:Documentation 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.
BaseModel or BaseBasicModel. These classes live in the FoundationKit.Domain.Models namespace and give every table a consistent, predictable shape — a stable primary key, creation and update timestamps, a soft-delete flag, and optional audit fields that record who created or last modified a record. By inheriting from one of these classes instead of writing those fields by hand each time, you get repository support, soft-delete behaviour, and pagination for free, because FoundationKit’s generic repository types are constrained to BaseModel.
Properties at a glance
The following table lists every property defined acrossBaseModel and BaseBasicModel, its type, whether it is persisted by EF Core, and what it is used for.
| Property | Type | Persisted | Description |
|---|---|---|---|
Id | Guid | ✅ Yes | Primary key. Generated by the application layer before insert. |
CreatedAt | DateTime | ✅ Yes | Timestamp set when the record is first created. |
UpdatedAt | DateTime? | ✅ Yes | Timestamp to be set on updates. Nullable — null means never updated. Must be set by the application layer; the base class does not auto-populate it. |
IsDeleted | bool | ✅ Yes | Soft-delete flag. true means the record is logically deleted but still present in the database. |
CreatedBy | string? | ✅ Yes (BaseModel) / ❌ No (BaseBasicModel) | Identifier of the user who created the record. |
UpdatedBy | string? | ✅ Yes (BaseModel) / ❌ No (BaseBasicModel) | Identifier of the user who last updated the record. |
CreatedAtStr | string | ❌ [NotMapped] | Computed display string: CreatedAt formatted as dd/MM/yyyy hh:mm:ss. |
UpdateAtStr | string | ❌ [NotMapped] | Computed display string: UpdatedAt formatted as dd/MM/yyyy hh:mm:ss, or "" if null. |
BaseModel
BaseModel is the root abstract class. Inherit from it when you need full audit tracking — the CreatedBy and UpdatedBy columns are mapped to real database columns, so you can query which user created or modified any row.
Inheriting BaseModel
Declare your entity class aspublic class MyEntity : BaseModel and add only the domain-specific properties. EF Core will migrate Id, CreatedAt, UpdatedAt, IsDeleted, CreatedBy, and UpdatedBy as real columns.
Id, CreatedAt, UpdatedAt, IsDeleted, CreatedBy, UpdatedBy, InvoiceNumber, Amount, CustomerId.
BaseBasicModel
BaseBasicModel extends BaseModel but overrides CreatedBy and UpdatedBy with the [NotMapped] attribute. The properties still exist on the C# object — you can assign them freely at runtime — but EF Core will not create or write to CreatedBy/UpdatedBy columns in the database. This is the right choice for tables where audit trail by user is unnecessary and you want to keep the schema lean.
Inheriting BaseBasicModel
Id, CreatedAt, UpdatedAt, IsDeleted, Name, Slug — no audit columns.
BaseModel vs BaseBasicModel — which should I use?Choose
BaseModel when you need to persist who created or last modified a record (e.g. orders, invoices, user-generated content). Choose BaseBasicModel when the entity is managed by the system rather than individual users (e.g. lookup tables, categories, configuration records) and you want to avoid the overhead of tracking audit columns in the database. Both expose the same Id, CreatedAt, UpdatedAt, and IsDeleted fields.Soft-delete with IsDeleted
FoundationKit treats deletion as a state change rather than a destructive operation. When you callSoftRemoveAsync on a repository, the entity row is not removed from the database. Instead, the IsDeleted flag is set to true and the change is committed inside a transaction.
.Where(x => !x.IsDeleted) predicate (or use a global query filter in your DbContext) to ensure soft-deleted records do not appear in results. If you genuinely need to erase a row from the database, call RemoveAsync instead, which issues a real DELETE.
Computed [NotMapped] display strings
CreatedAtStr and UpdateAtStr are convenience properties intended for serialisation scenarios where you want a pre-formatted, human-readable date string instead of a raw DateTime. Because they carry [NotMapped], EF Core never attempts to read them from or write them to the database — they are computed on the fly from CreatedAt and UpdatedAt respectively.
BaseOutput so they appear automatically in your API responses without any additional mapping configuration.