ModelConfigurationBuilder Class

Definition

Provides a simple API surface for setting defaults and configuring conventions before they run.

You can use ModelConfigurationBuilder to configure the conventions for a context by overriding ConfigureConventions(ModelConfigurationBuilder) on your derived context. Alternatively you can create the model externally and set it on a DbContextOptions instance that is passed to the context constructor.

public class ModelConfigurationBuilder
type ModelConfigurationBuilder = class
Public Class ModelConfigurationBuilder
Inheritance
ModelConfigurationBuilder

Remarks

See Pre-convention model building in EF Core for more information.

Constructors

ModelConfigurationBuilder(ConventionSet)

Initializes a new instance of the ModelConfigurationBuilder.

Properties

ModelConfiguration

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

Methods

CreateModelBuilder(ModelDependencies)

Creates the configured ModelBuilder used to create the model. This is done automatically when using OnModelCreating(ModelBuilder); this method allows it to be run explicitly in cases where the automatic execution is not possible.

DefaultTypeMapping(Type)

Marks the given type as a scalar, even when used outside of entity types. This allows values of this type to be used in queries that are not referencing property of this type.

Unlike Properties(Type) this method should only be called on a non-nullable concrete type. Calling it on a base type will not apply the configuration to the derived types.

Calling this is rarely needed. If there are properties of the given type calling Properties(Type) should be enough in most cases.

DefaultTypeMapping(Type, Action<TypeMappingConfigurationBuilder>)

Marks the given type as a scalar, even when used outside of entity types. This allows values of this type to be used in queries that are not referencing property of this type.

Unlike Properties(Type) this method should only be called on a non-nullable concrete type. Calling it on a base type will not apply the configuration to the derived types.

Calling this is rarely needed. If there are properties of the given type calling Properties(Type) should be enough in most cases.

DefaultTypeMapping<TScalar>()

Marks the given type as a scalar, even when used outside of entity types. This allows values of this type to be used in queries that are not referencing property of this type.

Unlike Properties<TProperty>() this method should only be called on a non-nullable concrete type. Calling it on a base type will not apply the configuration to the derived types.

Calling this is rarely needed. If there are properties of the given type calling Properties<TProperty>() should be enough in most cases.

DefaultTypeMapping<TScalar>(Action<TypeMappingConfigurationBuilder<TScalar>>)

Marks the given type as a scalar, even when used outside of entity types. This allows values of this type to be used in queries that are not referencing property of this type.

Unlike Properties<TProperty>() this method should only be called on a non-nullable concrete type. Calling it on a base type will not apply the configuration to the derived types.

Calling this is rarely needed. If there are properties of the given type calling Properties<TProperty>() should be enough in most cases.

IgnoreAny(Type)

Prevents the conventions from the given type from discovering properties of the given or derived types.

IgnoreAny<T>()

Prevents the conventions from the given type from discovering properties of the given or derived types.

Properties(Type)

Marks the given and derived types as corresponding to entity type properties.

This can also be called on an interface or an unbound generic type to apply the configuration to all properties of implementing and constructed types.

Properties(Type, Action<PropertiesConfigurationBuilder>)

Marks the given and derived types as corresponding to entity type properties.

This can also be called on an interface or an unbound generic type to apply the configuration to all properties of implementing and constructed types.

Properties<TProperty>()

Marks the given and derived types as corresponding to entity type properties.

This can also be called on an interface to apply the configuration to all properties of implementing types.

Properties<TProperty>(Action<PropertiesConfigurationBuilder<TProperty>>)

Marks the given and derived types as corresponding to entity type properties.

This can also be called on an interface to apply the configuration to all properties of implementing types.

Applies to