Notification Entity Mappings
Summary
All mapping is fluent, declared inline in a single OnModelCreating method. There are no separate configuration classes, no mapping attributes on the entities and no assembly scan.
Audience
Engineers, architects, QA and support.
Reference Content
The verified reference material for this topic is set out in the sections below.
Configuration style
Each entity is configured through a local builder variable in one contiguous block: table name, key, property constraints, then indexes. IEntityTypeConfiguration is not used anywhere, and ApplyConfigurationsFromAssembly is not called. The entity classes themselves are plain — no data annotations, no attributes, no base class and no interface.
Keys
Every entity declares an explicit HasKey on an Id property of type GUID. Every entity initialises that property to a newly generated GUID in its field initialiser, so keys are assigned client-side before insert rather than by the database. No entity uses a composite key, and no entity uses a database-generated key.
Required properties
Seventeen properties across the model are marked required:
| Entity | Required properties |
|---|---|
| Templates | template key, channel |
| Recipients | recipient type, external reference |
| Messages | template key, channel, status |
| Delivery attempts | channel, provider, status |
| Preferences | recipient type, external reference, event type, channel |
| Audit log | stage |
| Idempotency ledger | event type, outcome |
Every other mapped property is nullable or a non-nullable value type. Notably TenantId is optional on all six entities that carry it.
String lengths
Lengths are set explicitly and consistently by role:
| Role | Length |
|---|---|
| Tenant identifier | 80 |
| Channel, recipient type, status, stage, outcome | 40 |
| Template key, event type, correlation identifier | 160 |
| External reference | 200 |
| Email and delivery address | 320 |
| Display name | 300 |
| Provider | 60 |
| Source service | 120 |
| Subject | 1000 |
| Error and detail text | 2000 |
| Description | 500 |
| Locale | 35 |
| Trace identifier | 64 |
| Phone | 40 |
Column types
Two properties declare an explicit column type of text rather than a bounded string: the template body and the message body. These are the only unbounded text columns in the schema.
Not configured
The following mapping features appear nowhere in the model:
- No
HasDefaultValueorHasDefaultValueSql— every default is a property initialiser in C# and exists only in application memory, so a row inserted outside the application receives no default. - No
HasPrecisionorHasScale— the model contains no decimal or money property. - No
OnDeleteor delete behavior — there are no relationships to configure it on. - No
HasConversion,OwnsOne,OwnsMany,ComplexPropertyorToJson. - No
IsRowVersion,IsConcurrencyTokenor shadow property. - No
HasComputedColumnSql, check constraint, sequence or database function mapping.
Classification
Implemented.
Requires confirmation
Whether database-side defaults are intended for insert paths outside the application requires confirmation.
Related Articles
See Also
Keywords
- Notification database
- Entity Mappings
- Draft database documentation
Source References
microservices/src/notification-service/Infrastructure/NotificationDbContext.csmicroservices/src/notification-service/Domain/NotificationEntities.csmicroservices/src/notification-service/Infrastructure/Migrations/NotificationDbContextModelSnapshot.csmicroservices/src/notification-service/Infrastructure/Migrations/20260705113059_InitialNotificationSchema.cs
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Review cycle: Quarterly