Class RelationalModelValidator
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
The validator that enforces rules common for all relational providers.
The service lifetime is Singleton. This means a single instance is used by many Microsoft.EntityFrameworkCore.DbContext instances. The implementation must be thread-safe. This service cannot depend on services registered as Scoped.
public class RelationalModelValidator : ModelValidator- Inheritance
- 
      
      RelationalModelValidator
Constructors
RelationalModelValidator(ModelValidatorDependencies, RelationalModelValidatorDependencies)
Creates a new instance of RelationalModelValidator.
public RelationalModelValidator(ModelValidatorDependencies dependencies, RelationalModelValidatorDependencies relationalDependencies)Parameters
- dependenciesModelValidatorDependencies
- Parameter object containing dependencies for this service. 
- relationalDependenciesRelationalModelValidatorDependencies
- Parameter object containing relational dependencies for this service. 
Properties
RelationalDependencies
Dependencies used to create a Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator
protected virtual RelationalModelValidatorDependencies RelationalDependencies { get; }Property Value
Methods
GetDefaultColumnValue(IProperty, in StoreObjectIdentifier)
Returns the object that is used as the default value for the column the property is mapped to.
protected virtual object GetDefaultColumnValue(IProperty property, in StoreObjectIdentifier storeObject)Parameters
- propertyIProperty
- The property to get the default value for. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
Returns
- object
- The object that is used as the default value for the column the property is mapped to. 
Validate(IModel, IDiagnosticsLogger<Validation>)
Validates a model, throwing an exception if any errors are found.
public override void Validate(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateBoolsWithDefaults(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of bool properties in the model.
protected virtual void ValidateBoolsWithDefaults(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateCompatible(IForeignKey, IForeignKey, string, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of two foreign keys mapped to the same foreign key constraint.
protected virtual void ValidateCompatible(IForeignKey foreignKey, IForeignKey duplicateForeignKey, string foreignKeyName, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- foreignKeyIForeignKey
- A foreign key. 
- duplicateForeignKeyIForeignKey
- Another foreign key. 
- foreignKeyNamestring
- The foreign key constraint name. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateCompatible(IIndex, IIndex, string, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of two indexes mapped to the same table index.
protected virtual void ValidateCompatible(IIndex index, IIndex duplicateIndex, string indexName, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- indexIIndex
- An index. 
- duplicateIndexIIndex
- Another index. 
- indexNamestring
- The name of the index. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateCompatible(IKey, IKey, string, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of two keys mapped to the same unique constraint.
protected virtual void ValidateCompatible(IKey key, IKey duplicateKey, string keyName, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- keyIKey
- A key. 
- duplicateKeyIKey
- Another key. 
- keyNamestring
- The name of the unique constraint. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateCompatible(IProperty, IProperty, string, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of two properties mapped to the same column.
protected virtual void ValidateCompatible(IProperty property, IProperty duplicateProperty, string columnName, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- propertyIProperty
- A property. 
- duplicatePropertyIProperty
- Another property. 
- columnNamestring
- The column name. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateDbFunctions(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of functions in the model.
protected virtual void ValidateDbFunctions(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateDefaultValuesOnKeys(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of default values in the model.
protected virtual void ValidateDefaultValuesOnKeys(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateIndexProperties(IModel, IDiagnosticsLogger<Validation>)
Validates that the properties of any one index are all mapped to columns on at least one common table.
protected virtual void ValidateIndexProperties(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateInheritanceMapping(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of inheritance in the model.
protected override void ValidateInheritanceMapping(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidatePropertyOverrides(IModel, IDiagnosticsLogger<Validation>)
Validates the table-specific property overrides.
protected virtual void ValidatePropertyOverrides(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedColumnsCompatibility(IReadOnlyList<IEntityType>, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of properties sharing columns in a given table-like object.
protected virtual void ValidateSharedColumnsCompatibility(IReadOnlyList<IEntityType> mappedTypes, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedForeignKeysCompatibility(IReadOnlyList<IEntityType>, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of foreign keys in a given shared table.
protected virtual void ValidateSharedForeignKeysCompatibility(IReadOnlyList<IEntityType> mappedTypes, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedIndexesCompatibility(IReadOnlyList<IEntityType>, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of indexes in a given shared table.
protected virtual void ValidateSharedIndexesCompatibility(IReadOnlyList<IEntityType> mappedTypes, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedKeysCompatibility(IReadOnlyList<IEntityType>, in StoreObjectIdentifier, IDiagnosticsLogger<Validation>)
Validates the compatibility of primary and alternate keys in a given shared table.
protected virtual void ValidateSharedKeysCompatibility(IReadOnlyList<IEntityType> mappedTypes, in StoreObjectIdentifier storeObject, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- storeObjectStoreObjectIdentifier
- The identifier of the store object. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedTableCompatibility(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of shared tables in the model.
protected virtual void ValidateSharedTableCompatibility(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedTableCompatibility(IReadOnlyList<IEntityType>, string, string, IDiagnosticsLogger<Validation>)
Validates the compatibility of entity types sharing a given table.
protected virtual void ValidateSharedTableCompatibility(IReadOnlyList<IEntityType> mappedTypes, string tableName, string schema, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- tableNamestring
- The table name. 
- schemastring
- The schema. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedViewCompatibility(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of shared views in the model.
protected virtual void ValidateSharedViewCompatibility(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSharedViewCompatibility(IReadOnlyList<IEntityType>, string, string, IDiagnosticsLogger<Validation>)
Validates the compatibility of entity types sharing a given view.
protected virtual void ValidateSharedViewCompatibility(IReadOnlyList<IEntityType> mappedTypes, string viewName, string schema, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- mappedTypesIReadOnlyList<IEntityType>
- The mapped entity types. 
- viewNamestring
- The view name. 
- schemastring
- The schema. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use. 
ValidateSqlQueries(IModel, IDiagnosticsLogger<Validation>)
Validates the mapping/configuration of SQL queries in the model.
protected virtual void ValidateSqlQueries(IModel model, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)Parameters
- modelIModel
- The model to validate. 
- loggerIDiagnosticsLogger<Validation>
- The logger to use.