Interface IModelCustomizer
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
Performs additional configuration of the model in addition to what is discovered by convention.
This interface is typically used by database providers (and other extensions). It is generally not used in application code.
public interface IModelCustomizer
Remarks
When replacing this service consider deriving the implementation from ModelCustomizer or Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelCustomizer to preserve the default behavior.
The service lifetime is Singleton. This means a single instance is used by many DbContext instances. The implementation must be thread-safe. This service cannot depend on services registered as Scoped.
See Implementation of database providers and extensions for more information and examples.
Methods
Customize(ModelBuilder, DbContext)
Builds the model for a given context.
void Customize(ModelBuilder modelBuilder, DbContext context)
Parameters
modelBuilder
ModelBuilderThe builder being used to construct the model.
context
DbContextThe context instance that the model is being created for.
Remarks
If any instance data from context
is
used when building the model, then the implementation of Create(DbContext, bool)
also needs to be updated to ensure the model is cached correctly.