Skip to main content

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:

EntityRequired properties
Templatestemplate key, channel
Recipientsrecipient type, external reference
Messagestemplate key, channel, status
Delivery attemptschannel, provider, status
Preferencesrecipient type, external reference, event type, channel
Audit logstage
Idempotency ledgerevent 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:

RoleLength
Tenant identifier80
Channel, recipient type, status, stage, outcome40
Template key, event type, correlation identifier160
External reference200
Email and delivery address320
Display name300
Provider60
Source service120
Subject1000
Error and detail text2000
Description500
Locale35
Trace identifier64
Phone40

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 HasDefaultValue or HasDefaultValueSql — 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 HasPrecision or HasScale — the model contains no decimal or money property.
  • No OnDelete or delete behavior — there are no relationships to configure it on.
  • No HasConversion, OwnsOne, OwnsMany, ComplexProperty or ToJson.
  • No IsRowVersion, IsConcurrencyToken or 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.

See Also

Keywords

  • Notification database
  • Entity Mappings
  • Draft database documentation

Source References

  • microservices/src/notification-service/Infrastructure/NotificationDbContext.cs
  • microservices/src/notification-service/Domain/NotificationEntities.cs
  • microservices/src/notification-service/Infrastructure/Migrations/NotificationDbContextModelSnapshot.cs
  • microservices/src/notification-service/Infrastructure/Migrations/20260705113059_InitialNotificationSchema.cs

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-21
  • Review cycle: Quarterly