FoundationKit ships two abstract EF CoreDocumentation 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.
DbContext base classes that take care of the most repetitive concern in any data layer: keeping CreatedAt and UpdatedAt accurate on every save operation. Both classes intercept SaveChanges and SaveChangesAsync, walk the change tracker for any entities that derive from BaseModel, and stamp the correct timestamp — either local time or UTC — depending on a single application-wide flag. You pick the right class based on whether your application also uses ASP.NET Core Identity.
FoundationKitDbContext
FoundationKitDbContext is an abstract class that extends EF Core’s DbContext. Inherit from it when your application does not use ASP.NET Core Identity.
Behaviour summary
| Entity state | Field set | Value |
|---|---|---|
Added | CreatedAt | DateTime.UtcNow or DateTime.Now |
Modified | UpdatedAt | DateTime.UtcNow or DateTime.Now |
| Any other state | (nothing) | — |
BaseModel are affected. Plain EF Core entities that do not inherit from BaseModel are untouched.
Defining your application DbContext
Registration in Program.cs
FoundationKitIdentityDbContext<TUser>
FoundationKitIdentityDbContext<TUser> provides identical timestamp automation but inherits from IdentityDbContext<TUser> instead of plain DbContext. Use this variant when your application authenticates users through ASP.NET Core Identity.
TUser is constrained to IdentityUser, meaning you can pass either the built-in IdentityUser or your own extended user class.
Defining your Identity-aware application DbContext
Registration in Program.cs
FoundationKitStaticOptions
FoundationKitStaticOptions is a lightweight static class that controls global behaviour shared across both context implementations.
When
false (the default), both FoundationKitDbContext and
FoundationKitIdentityDbContext use DateTime.Now (local server time).
When true, they use DateTime.UtcNow. Set this flag once at application
startup, before any database operations are performed.Setting DateUtc in Program.cs
Set
DateUtc consistently across every entry point in your application
(web host, worker services, migration tooling, integration tests). Mixing
local and UTC timestamps in the same table will produce ordering and
comparison bugs that are difficult to diagnose. If your deployment
environment spans multiple time zones or runs in containers, prefer
DateUtc = true.