Delen via


ModelValidator Class

Definition

The validator that enforces core rules common for all providers.

public class ModelValidator : Microsoft.EntityFrameworkCore.Infrastructure.IModelValidator
type ModelValidator = class
    interface IModelValidator
Public Class ModelValidator
Implements IModelValidator
Inheritance
ModelValidator
Derived
Implements

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

ModelValidator(ModelValidatorDependencies)

Creates a new instance of ModelValidator.

Properties

Dependencies

Dependencies for this service.

Methods

IsOwned(Type, IConventionModel)

Returns a value indicating whether that target CLR type would correspond to an owned entity type.

IsRedundant(IForeignKey)

Returns a value indicating whether the given foreign key is redundant.

LogShadowProperties(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Logs all shadow properties that were created because there was no matching CLR member.

LogShadowProperties(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ThrowPropertyNotMappedException(String, IConventionEntityType, IConventionProperty)

Throws an InvalidOperationException with a message containing provider-specific information, when available, indicating possible reasons why the property cannot be mapped.

ThrowPropertyNotMappedException(String, IConventionTypeBase, IConventionProperty)

Throws an InvalidOperationException with a message containing provider-specific information, when available, indicating possible reasons why the property cannot be mapped.

Validate(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates a model, throwing an exception if any errors are found.

Validate(IModel)

Validates a model, throwing an exception if any errors are found.

ValidateChangeTrackingStrategy(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of change tracking in the model.

ValidateChangeTrackingStrategy(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateClrInheritance(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of inheritance in the model.

ValidateClrInheritance(IModel, IEntityType, HashSet<IEntityType>)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateClrInheritance(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateData(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of data (e.g. seed data) in the model.

ValidateData(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateDefiningNavigations(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)
Obsolete.

Validates the mapping/configuration of defining navigations in the model.

ValidateDefiningNavigations(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateDefiningQuery(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of defining queries in the model.

ValidateDiscriminatorValues(IEntityType)

Validates the discriminator and values for all entity types derived from the given one.

ValidateDiscriminatorValues(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)
Obsolete.

Validates the mapping/configuration of inheritance in the model.

ValidateEntityClrTypes(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates that common CLR types are not mapped accidentally as entity types.

ValidateFieldMapping(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of properties mapped to fields in the model.

ValidateFieldMapping(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateForeignKeys(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of foreign keys in the model.

ValidateForeignKeys(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateIgnoredMembers(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates that no attempt is made to ignore inherited properties.

ValidateInheritanceMapping(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping of inheritance in the model.

ValidateKeylessTypes(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of entity types without keys in the model.

ValidateNoCycles(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of the model for cycles.

ValidateNoCycles(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateNoMutableKeys(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of mutable in the model.

ValidateNoMutableKeys(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateNonNullPrimaryKeys(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates that all trackable entity types have a primary key.

ValidateNonNullPrimaryKeys(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateNoShadowEntities(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)
Obsolete.

Validates that the model does not contain any entity types without a corresponding CLR type.

ValidateNoShadowEntities(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateNoShadowKeys(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of shadow keys in the model.

ValidateNoShadowKeys(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateOwnership(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of ownership in the model.

ValidateOwnership(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidatePrimitiveCollections(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping of primitive collection properties the model.

ValidatePropertyMapping(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates property mappings.

ValidateQueryFilters(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the mapping/configuration of query filters in the model.

ValidateQueryFilters(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateQueryTypes(IModel)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

ValidateRelationships(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates relationships.

ValidateTriggers(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates triggers.

ValidateTypeMappings(IModel, IDiagnosticsLogger<DbLoggerCategory.Model.Validation>)

Validates the type mapping of properties the model.

Applies to