Every entity that inherits fromDocumentation 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 carries an IsDeleted flag for
soft-delete support. For that flag to be useful, it must be enforced at the
query layer automatically — otherwise every developer on the team has to
remember to add a .Where(x => !x.IsDeleted) clause to every LINQ query.
EFCoreConfiguration<TEntity> solves this by registering a global EF Core
query filter the moment a configuration class is applied, and then delegating
to your own ConfigureEF implementation for entity-specific column mappings,
indexes, and relationships.
EFCoreConfiguration<TEntity>
Members
The method called by EF Core’s model-building pipeline when it applies this
configuration. It first registers
HasQueryFilter(x => !x.IsDeleted) on
the entity, then forwards to ConfigureEF for any additional configuration
you supply. You should not override or call this method yourself.Implement this method to provide entity-specific configuration — column
names, string lengths, required constraints, indexes, relationships, and
so on. It is called by
Configure after the query filter has been applied,
so the filter is always in place regardless of what you do inside
ConfigureEF.The global query filter
CallingHasQueryFilter(x => !x.IsDeleted) in Configure instructs EF Core
to append AND IsDeleted = 0 (or the database equivalent) to every SQL
query that targets TEntity, including those performed through navigation
properties. This means your repositories and service methods stay clean:
When you genuinely need to include soft-deleted records — for example in an
admin restore endpoint or a data-export job — call
.IgnoreQueryFilters()
on the specific query:IgnoreQueryFilters() removes all global filters from that query,
not just the soft-delete one, so be mindful if you have applied additional
filters in your configuration.Implementing a configuration class
Derive fromEFCoreConfiguration<TEntity> and implement ConfigureEF to
describe your entity’s schema. The example below configures a Person entity
with custom column names, a max-length constraint, a unique index on the email
address, and a required relationship to a Department.
Registering configurations in OnModelCreating
Register all configurations at once by scanning the assembly that contains them:MigrationDbContextConfigAssembly
MigrationDbContextConfigAssembly is an advanced utility that extends EF
Core’s internal MigrationsAssembly to support schema-aware migrations. It
enables migrations to accept an IDbContextSchema constructor parameter,
allowing the same migration class to run against multiple schemas at runtime.
EncryptorOption
EncryptorOption is a configuration class for FoundationKit’s encryption
utilities. Bind it from appsettings.json or register it through the options
pattern.
Base64-encoded public key used for asymmetric encryption operations.
Store this in a secrets manager or an environment variable rather than
directly in
appsettings.json.Base64-encoded private key. Must be kept confidential. Never commit this
value to source control.
The name of the HTTP request header that carries AES configuration data
(for example
"AES"). Used by FoundationKit middleware to locate the
AES context for a given request.The text encoding used when converting between strings and byte arrays
during encryption and decryption. Note: the property name is spelled
Enconding (without the second d) in the source — use that exact name
when binding from configuration or referencing the property in code.