Skip to content

Model-bound constraints

Model-bound constraints let you declare uniqueness rules directly on event types using attributes. No separate constraint class is needed — adorn the event type or its properties with attributes, and Chronicle registers the constraints automatically when the client starts.

Use model-bound constraints when:

  • The uniqueness rule applies to a single event type
  • You want constraint metadata co-located with the event type it protects
  • You want the simplest possible syntax
TypeDescription
Unique propertyEnforce that a property value is unique across one or more event types
Unique event typeEnforce that only one event of a specific type can be appended per event source

Chronicle scans all loaded assemblies for types adorned with [Unique] and [RemoveConstraint] and registers the constraints with the Kernel automatically when the client starts. No explicit registration is required.