Table of Contents

Class ModelRuntimeInitializer

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

Initializes a IModel with the runtime dependencies.

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

public class ModelRuntimeInitializer : IModelRuntimeInitializer
Inheritance
ModelRuntimeInitializer
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

ModelRuntimeInitializer(ModelRuntimeInitializerDependencies)

Creates a new ModelRuntimeInitializer instance.

public ModelRuntimeInitializer(ModelRuntimeInitializerDependencies dependencies)

Parameters

dependencies ModelRuntimeInitializerDependencies

The dependencies to use.

Properties

Dependencies

Dependencies for this service.

protected virtual ModelRuntimeInitializerDependencies Dependencies { get; }

Property Value

ModelRuntimeInitializerDependencies

Methods

Initialize(IModel, bool, IDiagnosticsLogger<Validation>?)

Validates and initializes the given model with runtime dependencies.

public virtual IModel Initialize(IModel model, bool designTime = true, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>? validationLogger = null)

Parameters

model IModel

The model to initialize.

designTime bool

Whether the model should contain design-time configuration.

validationLogger IDiagnosticsLogger<DbLoggerCategory.Model.Validation>

The validation logger.

Returns

IModel

The initialized model.

InitializeModel(IModel, bool, bool)

Initializes the given model with runtime dependencies.

protected virtual void InitializeModel(IModel model, bool designTime, bool prevalidation)

Parameters

model IModel

The model to initialize.

designTime bool

Whether the model should contain design-time configuration.

prevalidation bool

true indicates that only pre-validation initialization should be performed; false indicates that only post-validation initialization should be performed.