Class ForeignKeyIndexConvention
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Conventions
- Assembly
- Microsoft.EntityFrameworkCore.dll
A convention that creates indexes on foreign key properties unless they are already covered by existing indexes or keys.
public class ForeignKeyIndexConvention : IForeignKeyAddedConvention, IForeignKeyRemovedConvention, IForeignKeyPropertiesChangedConvention, IForeignKeyUniquenessChangedConvention, IKeyAddedConvention, IKeyRemovedConvention, IEntityTypeBaseTypeChangedConvention, IIndexAddedConvention, IIndexRemovedConvention, IIndexUniquenessChangedConvention, IModelFinalizingConvention, IConvention
- Inheritance
-
ForeignKeyIndexConvention
- Implements
- Inherited Members
Remarks
See Model building conventions for more information and examples.
Constructors
ForeignKeyIndexConvention(ProviderConventionSetBuilderDependencies)
Creates a new instance of ForeignKeyIndexConvention.
public ForeignKeyIndexConvention(ProviderConventionSetBuilderDependencies dependencies)
Parameters
dependencies
ProviderConventionSetBuilderDependenciesParameter object containing dependencies for this convention.
Properties
Dependencies
Dependencies for this service.
protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; }
Property Value
Methods
AreIndexedBy(IReadOnlyList<IConventionProperty>, bool, IReadOnlyList<IConventionProperty>, bool)
Returns a value indicating whether the given properties are already covered by an existing index.
protected virtual bool AreIndexedBy(IReadOnlyList<IConventionProperty> properties, bool unique, IReadOnlyList<IConventionProperty> coveringIndexProperties, bool coveringIndexUnique)
Parameters
properties
IReadOnlyList<IConventionProperty>The properties to check.
unique
boolWhether the index to create should be unique.
coveringIndexProperties
IReadOnlyList<IConventionProperty>The properties of an existing index.
coveringIndexUnique
boolWhether the existing index is unique.
Returns
CreateIndex(IReadOnlyList<IConventionProperty>, bool, IConventionEntityTypeBuilder)
Creates an IConventionIndex.
protected virtual IConventionIndex? CreateIndex(IReadOnlyList<IConventionProperty> properties, bool unique, IConventionEntityTypeBuilder entityTypeBuilder)
Parameters
properties
IReadOnlyList<IConventionProperty>The properties that constitute the index.
unique
boolWhether the index to create should be unique.
entityTypeBuilder
IConventionEntityTypeBuilderThe builder for the entity type.
Returns
- IConventionIndex
The created index.
ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder, IConventionEntityType?, IConventionEntityType?, IConventionContext<IConventionEntityType>)
Called after the base type of an entity type changes.
public virtual void ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder entityTypeBuilder, IConventionEntityType? newBaseType, IConventionEntityType? oldBaseType, IConventionContext<IConventionEntityType> context)
Parameters
entityTypeBuilder
IConventionEntityTypeBuilderThe builder for the entity type.
newBaseType
IConventionEntityTypeThe new base entity type.
oldBaseType
IConventionEntityTypeThe old base entity type.
context
IConventionContext<IConventionEntityType>Additional information associated with convention execution.
ProcessForeignKeyAdded(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)
Called after a foreign key is added to the entity type.
public virtual void ProcessForeignKeyAdded(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<IConventionForeignKeyBuilder> context)
Parameters
relationshipBuilder
IConventionForeignKeyBuilderThe builder for the foreign key.
context
IConventionContext<IConventionForeignKeyBuilder>Additional information associated with convention execution.
ProcessForeignKeyPropertiesChanged(IConventionForeignKeyBuilder, IReadOnlyList<IConventionProperty>, IConventionKey, IConventionContext<IReadOnlyList<IConventionProperty>>)
Called after the foreign key properties or principal key are changed.
public virtual void ProcessForeignKeyPropertiesChanged(IConventionForeignKeyBuilder relationshipBuilder, IReadOnlyList<IConventionProperty> oldDependentProperties, IConventionKey oldPrincipalKey, IConventionContext<IReadOnlyList<IConventionProperty>> context)
Parameters
relationshipBuilder
IConventionForeignKeyBuilderThe builder for the foreign key.
oldDependentProperties
IReadOnlyList<IConventionProperty>The old foreign key properties.
oldPrincipalKey
IConventionKeyThe old principal key.
context
IConventionContext<IReadOnlyList<IConventionProperty>>Additional information associated with convention execution.
ProcessForeignKeyRemoved(IConventionEntityTypeBuilder, IConventionForeignKey, IConventionContext<IConventionForeignKey>)
Called after a foreign key is removed.
public virtual void ProcessForeignKeyRemoved(IConventionEntityTypeBuilder entityTypeBuilder, IConventionForeignKey foreignKey, IConventionContext<IConventionForeignKey> context)
Parameters
entityTypeBuilder
IConventionEntityTypeBuilderThe builder for the entity type.
foreignKey
IConventionForeignKeyThe removed foreign key.
context
IConventionContext<IConventionForeignKey>Additional information associated with convention execution.
ProcessForeignKeyUniquenessChanged(IConventionForeignKeyBuilder, IConventionContext<bool?>)
Called after the uniqueness for a foreign key is changed.
public virtual void ProcessForeignKeyUniquenessChanged(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)
Parameters
relationshipBuilder
IConventionForeignKeyBuilderThe builder for the foreign key.
context
IConventionContext<bool?>Additional information associated with convention execution.
ProcessIndexAdded(IConventionIndexBuilder, IConventionContext<IConventionIndexBuilder>)
Called after an index is added to the entity type.
public virtual void ProcessIndexAdded(IConventionIndexBuilder indexBuilder, IConventionContext<IConventionIndexBuilder> context)
Parameters
indexBuilder
IConventionIndexBuilderThe builder for the index.
context
IConventionContext<IConventionIndexBuilder>Additional information associated with convention execution.
ProcessIndexRemoved(IConventionEntityTypeBuilder, IConventionIndex, IConventionContext<IConventionIndex>)
Called after an index is removed.
public virtual void ProcessIndexRemoved(IConventionEntityTypeBuilder entityTypeBuilder, IConventionIndex index, IConventionContext<IConventionIndex> context)
Parameters
entityTypeBuilder
IConventionEntityTypeBuilderThe builder for the entity type.
index
IConventionIndexThe removed index.
context
IConventionContext<IConventionIndex>Additional information associated with convention execution.
ProcessIndexUniquenessChanged(IConventionIndexBuilder, IConventionContext<bool?>)
Called after the uniqueness for an index is changed.
public virtual void ProcessIndexUniquenessChanged(IConventionIndexBuilder indexBuilder, IConventionContext<bool?> context)
Parameters
indexBuilder
IConventionIndexBuilderThe builder for the index.
context
IConventionContext<bool?>Additional information associated with convention execution.
ProcessKeyAdded(IConventionKeyBuilder, IConventionContext<IConventionKeyBuilder>)
Called after a key is added to the entity type.
public virtual void ProcessKeyAdded(IConventionKeyBuilder keyBuilder, IConventionContext<IConventionKeyBuilder> context)
Parameters
keyBuilder
IConventionKeyBuilderThe builder for the key.
context
IConventionContext<IConventionKeyBuilder>Additional information associated with convention execution.
ProcessKeyRemoved(IConventionEntityTypeBuilder, IConventionKey, IConventionContext<IConventionKey>)
Called after a key is removed from the entity type.
public virtual void ProcessKeyRemoved(IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key, IConventionContext<IConventionKey> context)
Parameters
entityTypeBuilder
IConventionEntityTypeBuilderThe builder for the entity type.
key
IConventionKeyThe key.
context
IConventionContext<IConventionKey>Additional information associated with convention execution.
ProcessModelFinalizing(IConventionModelBuilder, IConventionContext<IConventionModelBuilder>)
public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)
Parameters
modelBuilder
IConventionModelBuildercontext
IConventionContext<IConventionModelBuilder>