Table of Contents

Class ValueGenerationConvention

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

A convention that configures store value generation as OnAdd on properties that are part of the primary key and not part of any foreign keys.

public class ValueGenerationConvention : IEntityTypePrimaryKeyChangedConvention, IForeignKeyAddedConvention, IForeignKeyRemovedConvention, IForeignKeyPropertiesChangedConvention, IEntityTypeBaseTypeChangedConvention, IForeignKeyOwnershipChangedConvention, IConvention
Inheritance
ValueGenerationConvention
Implements
Inherited Members

Remarks

See Model building conventions for more information and examples.

Constructors

ValueGenerationConvention(ProviderConventionSetBuilderDependencies)

Creates a new instance of ValueGenerationConvention.

public ValueGenerationConvention(ProviderConventionSetBuilderDependencies dependencies)

Parameters

dependencies ProviderConventionSetBuilderDependencies

Parameter object containing dependencies for this convention.

Properties

Dependencies

Dependencies for this service.

protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; }

Property Value

ProviderConventionSetBuilderDependencies

Methods

GetValueGenerated(IConventionProperty)

Returns the store value generation strategy to set for the given property.

protected virtual ValueGenerated? GetValueGenerated(IConventionProperty property)

Parameters

property IConventionProperty

The property.

Returns

ValueGenerated?

The store value generation strategy to set for the given property.

GetValueGenerated(IReadOnlyProperty)

Returns the store value generation strategy to set for the given property.

public static ValueGenerated? GetValueGenerated(IReadOnlyProperty property)

Parameters

property IReadOnlyProperty

The property.

Returns

ValueGenerated?

The store value generation strategy to set for the given property.

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 IConventionEntityTypeBuilder

The builder for the entity type.

newBaseType IConventionEntityType

The new base entity type.

oldBaseType IConventionEntityType

The old base entity type.

context IConventionContext<IConventionEntityType>

Additional information associated with convention execution.

ProcessEntityTypePrimaryKeyChanged(IConventionEntityTypeBuilder, IConventionKey?, IConventionKey?, IConventionContext<IConventionKey>)

Called after the primary key for an entity type is changed.

public virtual void ProcessEntityTypePrimaryKeyChanged(IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey? newPrimaryKey, IConventionKey? previousPrimaryKey, IConventionContext<IConventionKey> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder

The builder for the entity type.

newPrimaryKey IConventionKey

The new primary key.

previousPrimaryKey IConventionKey

The old primary key.

context IConventionContext<IConventionKey>

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 IConventionForeignKeyBuilder

The builder for the foreign key.

context IConventionContext<IConventionForeignKeyBuilder>

Additional information associated with convention execution.

ProcessForeignKeyOwnershipChanged(IConventionForeignKeyBuilder, IConventionContext<bool?>)

Called after the ownership value for a foreign key is changed.

public virtual void ProcessForeignKeyOwnershipChanged(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)

Parameters

relationshipBuilder IConventionForeignKeyBuilder

The builder for the foreign key.

context IConventionContext<bool?>

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 IConventionForeignKeyBuilder

The builder for the foreign key.

oldDependentProperties IReadOnlyList<IConventionProperty>

The old foreign key properties.

oldPrincipalKey IConventionKey

The 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 IConventionEntityTypeBuilder

The builder for the entity type.

foreignKey IConventionForeignKey

The removed foreign key.

context IConventionContext<IConventionForeignKey>

Additional information associated with convention execution.