Table of Contents

Class ModelCustomizer

Namespace
Microsoft.EntityFrameworkCore.Infrastructure
Assembly
Microsoft.EntityFrameworkCore.dll

Builds the model for a given context. This implementation builds the model by calling OnModelCreating(ModelBuilder) on the context.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public class ModelCustomizer : IModelCustomizer
Inheritance
ModelCustomizer
Implements
Inherited Members

Remarks

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.

Constructors

ModelCustomizer(ModelCustomizerDependencies)

Initializes a new instance of the ModelCustomizer class.

public ModelCustomizer(ModelCustomizerDependencies dependencies)

Parameters

dependencies ModelCustomizerDependencies

Parameter object containing dependencies for this service.

Properties

Dependencies

Dependencies for this service.

protected virtual ModelCustomizerDependencies Dependencies { get; }

Property Value

ModelCustomizerDependencies

Methods

Customize(ModelBuilder, DbContext)

Performs additional configuration of the model in addition to what is discovered by convention. This default implementation builds the model for a given context by calling OnModelCreating(ModelBuilder) on the context.

public virtual void Customize(ModelBuilder modelBuilder, DbContext context)

Parameters

modelBuilder ModelBuilder

The builder being used to construct the model.

context DbContext

The context instance that the model is being created for.