Table of Contents

Class ConventionSet

Namespace
Microsoft.EntityFrameworkCore.Metadata.Conventions
Assembly
Microsoft.EntityFrameworkCore.dll

Represents a set of conventions used to build a model.

public class ConventionSet
Inheritance
ConventionSet
Inherited Members

Remarks

See Model building conventions for more information and examples.

Constructors

ConventionSet()

public ConventionSet()

Properties

ComplexPropertyAddedConventions

Conventions to run when an entity type is added to the model.

public virtual List<IComplexPropertyAddedConvention> ComplexPropertyAddedConventions { get; }

Property Value

List<IComplexPropertyAddedConvention>

ComplexPropertyAnnotationChangedConventions

Conventions to run when an annotation is set or removed on a complex property.

public virtual List<IComplexPropertyAnnotationChangedConvention> ComplexPropertyAnnotationChangedConventions { get; }

Property Value

List<IComplexPropertyAnnotationChangedConvention>

ComplexPropertyFieldChangedConventions

Conventions to run when the field of a property is changed.

public virtual List<IComplexPropertyFieldChangedConvention> ComplexPropertyFieldChangedConventions { get; }

Property Value

List<IComplexPropertyFieldChangedConvention>

ComplexPropertyNullabilityChangedConventions

Conventions to run when the nullability of a property is changed.

public virtual List<IComplexPropertyNullabilityChangedConvention> ComplexPropertyNullabilityChangedConventions { get; }

Property Value

List<IComplexPropertyNullabilityChangedConvention>

ComplexPropertyRemovedConventions

Conventions to run when an entity type is removed.

public virtual List<IComplexPropertyRemovedConvention> ComplexPropertyRemovedConventions { get; }

Property Value

List<IComplexPropertyRemovedConvention>

ComplexTypeAnnotationChangedConventions

Conventions to run when an annotation is set or removed on a complex type.

public virtual List<IComplexTypeAnnotationChangedConvention> ComplexTypeAnnotationChangedConventions { get; }

Property Value

List<IComplexTypeAnnotationChangedConvention>

ComplexTypeMemberIgnoredConventions

Conventions to run when a property is ignored.

public virtual List<IComplexTypeMemberIgnoredConvention> ComplexTypeMemberIgnoredConventions { get; }

Property Value

List<IComplexTypeMemberIgnoredConvention>

DiscriminatorPropertySetConventions

Conventions to run when a discriminator property is set.

public virtual List<IDiscriminatorPropertySetConvention> DiscriminatorPropertySetConventions { get; }

Property Value

List<IDiscriminatorPropertySetConvention>

ElementTypeAnnotationChangedConventions

Conventions to run when an annotation is changed on the element of a collection.

public virtual List<IElementTypeAnnotationChangedConvention> ElementTypeAnnotationChangedConventions { get; }

Property Value

List<IElementTypeAnnotationChangedConvention>

ElementTypeNullabilityChangedConventions

Conventions to run when the nullability of the element of a collection is changed.

public virtual List<IElementTypeNullabilityChangedConvention> ElementTypeNullabilityChangedConventions { get; }

Property Value

List<IElementTypeNullabilityChangedConvention>

EntityTypeAddedConventions

Conventions to run when an entity type is added to the model.

public virtual List<IEntityTypeAddedConvention> EntityTypeAddedConventions { get; }

Property Value

List<IEntityTypeAddedConvention>

EntityTypeAnnotationChangedConventions

Conventions to run when an annotation is set or removed on an entity type.

public virtual List<IEntityTypeAnnotationChangedConvention> EntityTypeAnnotationChangedConventions { get; }

Property Value

List<IEntityTypeAnnotationChangedConvention>

EntityTypeBaseTypeChangedConventions

Conventions to run when the base entity type is changed.

public virtual List<IEntityTypeBaseTypeChangedConvention> EntityTypeBaseTypeChangedConventions { get; }

Property Value

List<IEntityTypeBaseTypeChangedConvention>

EntityTypeMemberIgnoredConventions

Conventions to run when a property is ignored.

public virtual List<IEntityTypeMemberIgnoredConvention> EntityTypeMemberIgnoredConventions { get; }

Property Value

List<IEntityTypeMemberIgnoredConvention>

EntityTypePrimaryKeyChangedConventions

Conventions to run when a primary key is changed.

public virtual List<IEntityTypePrimaryKeyChangedConvention> EntityTypePrimaryKeyChangedConventions { get; }

Property Value

List<IEntityTypePrimaryKeyChangedConvention>

EntityTypeRemovedConventions

Conventions to run when an entity type is removed.

public virtual List<IEntityTypeRemovedConvention> EntityTypeRemovedConventions { get; }

Property Value

List<IEntityTypeRemovedConvention>

ForeignKeyAddedConventions

Conventions to run when a foreign key is added.

public virtual List<IForeignKeyAddedConvention> ForeignKeyAddedConventions { get; }

Property Value

List<IForeignKeyAddedConvention>

ForeignKeyAnnotationChangedConventions

Conventions to run when an annotation is changed on a foreign key.

public virtual List<IForeignKeyAnnotationChangedConvention> ForeignKeyAnnotationChangedConventions { get; }

Property Value

List<IForeignKeyAnnotationChangedConvention>

ForeignKeyDependentRequirednessChangedConventions

Conventions to run when the requiredness of a foreign key is changed.

public virtual List<IForeignKeyDependentRequirednessChangedConvention> ForeignKeyDependentRequirednessChangedConventions { get; }

Property Value

List<IForeignKeyDependentRequirednessChangedConvention>

ForeignKeyNullNavigationSetConventions

Conventions to run when a navigation is set to null on a foreign key.

public virtual List<IForeignKeyNullNavigationSetConvention> ForeignKeyNullNavigationSetConventions { get; }

Property Value

List<IForeignKeyNullNavigationSetConvention>

ForeignKeyOwnershipChangedConventions

Conventions to run when the ownership of a foreign key is changed.

public virtual List<IForeignKeyOwnershipChangedConvention> ForeignKeyOwnershipChangedConventions { get; }

Property Value

List<IForeignKeyOwnershipChangedConvention>

ForeignKeyPrincipalEndChangedConventions

Conventions to run when the principal end of a relationship is configured.

public virtual List<IForeignKeyPrincipalEndChangedConvention> ForeignKeyPrincipalEndChangedConventions { get; }

Property Value

List<IForeignKeyPrincipalEndChangedConvention>

ForeignKeyPropertiesChangedConventions

Conventions to run when the properties or the principal key of a foreign key are changed.

public virtual List<IForeignKeyPropertiesChangedConvention> ForeignKeyPropertiesChangedConventions { get; }

Property Value

List<IForeignKeyPropertiesChangedConvention>

ForeignKeyRemovedConventions

Conventions to run when a foreign key is removed.

public virtual List<IForeignKeyRemovedConvention> ForeignKeyRemovedConventions { get; }

Property Value

List<IForeignKeyRemovedConvention>

ForeignKeyRequirednessChangedConventions

Conventions to run when the requiredness of a foreign key is changed.

public virtual List<IForeignKeyRequirednessChangedConvention> ForeignKeyRequirednessChangedConventions { get; }

Property Value

List<IForeignKeyRequirednessChangedConvention>

ForeignKeyUniquenessChangedConventions

Conventions to run when the uniqueness of a foreign key is changed.

public virtual List<IForeignKeyUniquenessChangedConvention> ForeignKeyUniquenessChangedConventions { get; }

Property Value

List<IForeignKeyUniquenessChangedConvention>

IndexAddedConventions

Conventions to run when an index is added.

public virtual List<IIndexAddedConvention> IndexAddedConventions { get; }

Property Value

List<IIndexAddedConvention>

IndexAnnotationChangedConventions

Conventions to run when an annotation is changed on an index.

public virtual List<IIndexAnnotationChangedConvention> IndexAnnotationChangedConventions { get; }

Property Value

List<IIndexAnnotationChangedConvention>

IndexRemovedConventions

Conventions to run when an index is removed.

public virtual List<IIndexRemovedConvention> IndexRemovedConventions { get; }

Property Value

List<IIndexRemovedConvention>

IndexSortOrderChangedConventions

Conventions to run when the sort order of an index is changed.

public virtual List<IIndexSortOrderChangedConvention> IndexSortOrderChangedConventions { get; }

Property Value

List<IIndexSortOrderChangedConvention>

IndexUniquenessChangedConventions

Conventions to run when the uniqueness of an index is changed.

public virtual List<IIndexUniquenessChangedConvention> IndexUniquenessChangedConventions { get; }

Property Value

List<IIndexUniquenessChangedConvention>

KeyAddedConventions

Conventions to run when a key is added.

public virtual List<IKeyAddedConvention> KeyAddedConventions { get; }

Property Value

List<IKeyAddedConvention>

KeyAnnotationChangedConventions

Conventions to run when an annotation is changed on a key.

public virtual List<IKeyAnnotationChangedConvention> KeyAnnotationChangedConventions { get; }

Property Value

List<IKeyAnnotationChangedConvention>

KeyRemovedConventions

Conventions to run when a key is removed.

public virtual List<IKeyRemovedConvention> KeyRemovedConventions { get; }

Property Value

List<IKeyRemovedConvention>

ModelAnnotationChangedConventions

Conventions to run when an annotation is set or removed on a model.

public virtual List<IModelAnnotationChangedConvention> ModelAnnotationChangedConventions { get; }

Property Value

List<IModelAnnotationChangedConvention>

ModelFinalizedConventions

Conventions to run when model validation is completed.

public virtual List<IModelFinalizedConvention> ModelFinalizedConventions { get; }

Property Value

List<IModelFinalizedConvention>

ModelFinalizingConventions

Conventions to run when model building is completed.

public virtual List<IModelFinalizingConvention> ModelFinalizingConventions { get; }

Property Value

List<IModelFinalizingConvention>

ModelInitializedConventions

Conventions to run to setup the initial model.

public virtual List<IModelInitializedConvention> ModelInitializedConventions { get; }

Property Value

List<IModelInitializedConvention>

NavigationAddedConventions

Conventions to run when a navigation property is added.

public virtual List<INavigationAddedConvention> NavigationAddedConventions { get; }

Property Value

List<INavigationAddedConvention>

NavigationAnnotationChangedConventions

Conventions to run when an annotation is changed on a navigation property.

public virtual List<INavigationAnnotationChangedConvention> NavigationAnnotationChangedConventions { get; }

Property Value

List<INavigationAnnotationChangedConvention>

NavigationRemovedConventions

Conventions to run when a navigation property is removed.

public virtual List<INavigationRemovedConvention> NavigationRemovedConventions { get; }

Property Value

List<INavigationRemovedConvention>

PropertyAddedConventions

Conventions to run when a property is added.

public virtual List<IPropertyAddedConvention> PropertyAddedConventions { get; }

Property Value

List<IPropertyAddedConvention>

PropertyAnnotationChangedConventions

Conventions to run when an annotation is changed on a property.

public virtual List<IPropertyAnnotationChangedConvention> PropertyAnnotationChangedConventions { get; }

Property Value

List<IPropertyAnnotationChangedConvention>

PropertyElementTypeChangedConventions

Conventions to run when the field of a property is changed.

public virtual List<IPropertyElementTypeChangedConvention> PropertyElementTypeChangedConventions { get; }

Property Value

List<IPropertyElementTypeChangedConvention>

PropertyFieldChangedConventions

Conventions to run when the field of a property is changed.

public virtual List<IPropertyFieldChangedConvention> PropertyFieldChangedConventions { get; }

Property Value

List<IPropertyFieldChangedConvention>

PropertyNullabilityChangedConventions

Conventions to run when the nullability of a property is changed.

public virtual List<IPropertyNullabilityChangedConvention> PropertyNullabilityChangedConventions { get; }

Property Value

List<IPropertyNullabilityChangedConvention>

PropertyRemovedConventions

Conventions to run when a property is removed.

public virtual List<IPropertyRemovedConvention> PropertyRemovedConventions { get; }

Property Value

List<IPropertyRemovedConvention>

SkipNavigationAddedConventions

Conventions to run when a skip navigation property is added.

public virtual List<ISkipNavigationAddedConvention> SkipNavigationAddedConventions { get; }

Property Value

List<ISkipNavigationAddedConvention>

SkipNavigationAnnotationChangedConventions

Conventions to run when an annotation is changed on a skip navigation property.

public virtual List<ISkipNavigationAnnotationChangedConvention> SkipNavigationAnnotationChangedConventions { get; }

Property Value

List<ISkipNavigationAnnotationChangedConvention>

SkipNavigationForeignKeyChangedConventions

Conventions to run when a skip navigation foreign key is changed.

public virtual List<ISkipNavigationForeignKeyChangedConvention> SkipNavigationForeignKeyChangedConventions { get; }

Property Value

List<ISkipNavigationForeignKeyChangedConvention>

SkipNavigationInverseChangedConventions

Conventions to run when a skip navigation inverse is changed.

public virtual List<ISkipNavigationInverseChangedConvention> SkipNavigationInverseChangedConventions { get; }

Property Value

List<ISkipNavigationInverseChangedConvention>

SkipNavigationRemovedConventions

Conventions to run when a skip navigation property is removed.

public virtual List<ISkipNavigationRemovedConvention> SkipNavigationRemovedConventions { get; }

Property Value

List<ISkipNavigationRemovedConvention>

TriggerAddedConventions

Conventions to run when a trigger property is added.

public virtual List<ITriggerAddedConvention> TriggerAddedConventions { get; }

Property Value

List<ITriggerAddedConvention>

TriggerRemovedConventions

Conventions to run when a trigger property is removed.

public virtual List<ITriggerRemovedConvention> TriggerRemovedConventions { get; }

Property Value

List<ITriggerRemovedConvention>

TypeIgnoredConventions

Conventions to run when a type is ignored.

public virtual List<ITypeIgnoredConvention> TypeIgnoredConventions { get; }

Property Value

List<ITypeIgnoredConvention>

Methods

Add(IConvention)

Adds a convention to the set.

public virtual void Add(IConvention convention)

Parameters

convention IConvention

The convention to add.

AddAfter<TConvention>(List<TConvention>, TConvention, Type)

Adds a convention after an existing convention.

public static bool AddAfter<TConvention>(List<TConvention> conventionsList, TConvention newConvention, Type existingConventionType)

Parameters

conventionsList List<TConvention>

The list of existing convention instances to scan.

newConvention TConvention

The new convention.

existingConventionType Type

The type of the existing convention.

Returns

bool

true if the convention was added.

Type Parameters

TConvention

The type of convention being added.

AddBefore<TConvention>(List<TConvention>, TConvention, Type)

Adds a convention before an existing convention.

public static bool AddBefore<TConvention>(List<TConvention> conventionsList, TConvention newConvention, Type existingConventionType)

Parameters

conventionsList List<TConvention>

The list of existing convention instances to scan.

newConvention TConvention

The new convention.

existingConventionType Type

The type of the existing convention.

Returns

bool

true if the convention was added.

Type Parameters

TConvention

The type of convention being added.

CreateConventionSet(DbContext)

Call this method to build a ConventionSet for only core services when using the ModelBuilder outside of OnModelCreating(ModelBuilder).

Note that it is unusual to use this method. Consider using DbContext in the normal way instead.

public static ConventionSet CreateConventionSet(DbContext context)

Parameters

context DbContext

Returns

ConventionSet

The convention set.

Remove(Type)

Removes the convention of the given type.

public virtual void Remove(Type conventionType)

Parameters

conventionType Type

The convention type to remove.

Remove<TConvention>(List<TConvention>, Type)

Removes an existing convention.

public static bool Remove<TConvention>(List<TConvention> conventionsList, Type existingConventionType)

Parameters

conventionsList List<TConvention>

The list of existing convention instances to scan.

existingConventionType Type

The type of the existing convention.

Returns

bool

true if the convention was removed.

Type Parameters

TConvention

The type of convention being removed.

Replace<TImplementation>(TImplementation)

Replaces an existing convention with a derived convention. Also registers the new convention for any convention types not implemented by the existing convention.

public virtual void Replace<TImplementation>(TImplementation newConvention) where TImplementation : IConvention

Parameters

newConvention TImplementation

The new convention.

Type Parameters

TImplementation

The type of the old convention.

Replace<TConvention, TImplementation>(List<TConvention>, TImplementation)

Replaces an existing convention with a derived convention.

public static bool Replace<TConvention, TImplementation>(List<TConvention> conventionsList, TImplementation newConvention) where TImplementation : TConvention

Parameters

conventionsList List<TConvention>

The list of existing convention instances to scan.

newConvention TImplementation

The new convention.

Returns

bool

true if the convention was replaced.

Type Parameters

TConvention

The type of convention being replaced.

TImplementation

The type of the old convention.