Skip to main content

Module registration

Module registration 

Source
Expand description

Compile-time entity registration via inventory.

The #[derive(EntityType)] macro emits an inventory::submit! for each entity type, registering a type-erased EntityRegistration. The DbContext discovers these at runtime via inventory::iter::<EntityRegistration>() (see DbContext::discover_entities).

Similarly, #[entity(T)] applied to impl IEntityTypeConfiguration<T> blocks emits an EntityConfigRegistration, whose apply_fn is invoked by DbContext::discover_entities() to apply Fluent API overrides to the ModelBuilder.

Structsยง

EntityConfigRegistration
Type-erased registration for an IEntityTypeConfiguration<T> impl block.
EntityRegistration
Type-erased registration for an entity type.