Every entity in a FoundationKit application ultimately derives 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 establish a consistent, convention-driven shape for all database-mapped types — covering primary key generation, automatic timestamp tracking, soft-delete support, and optional audit columns. Because every property is declared virtual, you can selectively override behaviour in individual entities without losing the framework’s built-in automation.
BaseModel
BaseModel is the root abstract class. All entities that need the full set of audit columns (CreatedBy, UpdatedBy) should inherit from it directly.
Properties
The primary key of the entity. Declared
virtual so EF Core’s change tracker
can proxy it, and so derived classes may override the getter/setter or add
database-specific annotations.The UTC or local timestamp at which the record was first saved. Set
automatically by
FoundationKitDbContext.SaveChanges[Async] whenever the
entity state is Added. You should not set this field manually.The UTC or local timestamp of the most recent modification. Set automatically
on
Modified state. Remains null until the entity is changed for the first
time after creation.If you need to override the column name in the database (e.g. to match a
legacy schema), add
[Column("UpdateAt")] to the overridden property in
your derived entity, as noted in the source XML docs.A
[NotMapped] computed property that formats CreatedAt as
"dd/MM/yyyy hh:mm:ss". Use this in DTOs or view models to avoid manual
formatting at the presentation layer.A
[NotMapped] computed property that formats UpdatedAt as
"dd/MM/yyyy hh:mm:ss", or returns an empty string "" when UpdatedAt
is null.Soft-delete flag. When
true the record is considered deleted, but it is
not physically removed from the database. EFCoreConfiguration<TEntity>
registers a global query filter x => !x.IsDeleted so that deleted records
are automatically excluded from all LINQ queries unless you explicitly call
.IgnoreQueryFilters().Audit column that stores the identifier (e.g. user ID or username) of the
principal that created the record. Not set automatically — your application
service or repository layer is responsible for populating this field before
calling
SaveChanges.Audit column that stores the identifier of the principal that last modified
the record. Same semantics as
CreatedBy.Usage example
BaseBasicModel
BaseBasicModel inherits from BaseModel and overrides both CreatedBy and
UpdatedBy with the [NotMapped] attribute. The effect is that EF Core will
not create columns for those two audit fields, while every other property
(Id, CreatedAt, UpdatedAt, IsDeleted, and the computed strings) is
mapped exactly as in BaseModel.
BaseBasicModel for reference-data tables, lookup lists, or any entity
where auditing who made changes is unnecessary and you want to keep the schema
clean.
Usage example
Choosing between the two
| Requirement | Use |
|---|---|
| Full audit trail (who created / last updated) | BaseModel |
| Timestamps and soft-delete only | BaseBasicModel |
| Reference / lookup data | BaseBasicModel |
| Domain aggregates with security requirements | BaseModel |
Virtual properties and EF Core proxies
All mapped properties on both classes are declaredvirtual. This has two
practical consequences:
-
EF Core lazy-loading proxies — if you enable lazy loading via
UseLazyLoadingProxies(), EF Core can generate proxy types for your entities. Proxies require that all navigation properties (and, by convention, all properties) arevirtual. - Override in derived classes — you can override any property to attach additional data annotations, change column names, or alter behaviour without modifying the base class.