# Class NpgsqlValueGenerationConvention

Namespace
  Npgsql.EntityFrameworkCore.PostgreSQL.Metadata.Conventions

Assembly
  Npgsql.EntityFrameworkCore.PostgreSQL.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, were configured to have a database default value or were configured to use a NpgsqlValueGenerationStrategy. It also configures properties as OnAddOrUpdate if they were configured as computed columns.

    public class NpgsqlValueGenerationConvention : RelationalValueGenerationConvention, IEntityTypePrimaryKeyChangedConvention, IForeignKeyAddedConvention, IForeignKeyRemovedConvention, IForeignKeyPropertiesChangedConvention, IEntityTypeBaseTypeChangedConvention, IForeignKeyOwnershipChangedConvention, IPropertyAnnotationChangedConvention, IEntityTypeAnnotationChangedConvention, IConvention

Inheritance
  object
  ValueGenerationConvention
  RelationalValueGenerationConvention
  NpgsqlValueGenerationConvention

Implements
  IEntityTypePrimaryKeyChangedConvention
  IForeignKeyAddedConvention
  IForeignKeyRemovedConvention
  IForeignKeyPropertiesChangedConvention
  IEntityTypeBaseTypeChangedConvention
  IForeignKeyOwnershipChangedConvention
  IPropertyAnnotationChangedConvention
  IEntityTypeAnnotationChangedConvention
  IConvention

Inherited Members
  RelationalValueGenerationConvention.ProcessEntityTypeAnnotationChanged(IConventionEntityTypeBuilder, string, IConventionAnnotation, IConventionAnnotation, IConventionContext<IConventionAnnotation>)
  RelationalValueGenerationConvention.MappingStrategyAllowsValueGeneration(IConventionProperty, string)
  RelationalValueGenerationConvention.RelationalDependencies
  ValueGenerationConvention.ProcessForeignKeyAdded(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)
  ValueGenerationConvention.ProcessForeignKeyRemoved(IConventionEntityTypeBuilder, IConventionForeignKey, IConventionContext<IConventionForeignKey>)
  ValueGenerationConvention.ProcessForeignKeyPropertiesChanged(IConventionForeignKeyBuilder, IReadOnlyList<IConventionProperty>, IConventionKey, IConventionContext<IReadOnlyList<IConventionProperty>>)
  ValueGenerationConvention.ProcessEntityTypePrimaryKeyChanged(IConventionEntityTypeBuilder, IConventionKey, IConventionKey, IConventionContext<IConventionKey>)
  ValueGenerationConvention.ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder, IConventionEntityType, IConventionEntityType, IConventionContext<IConventionEntityType>)
  ValueGenerationConvention.GetValueGenerated(IReadOnlyProperty)
  ValueGenerationConvention.ProcessForeignKeyOwnershipChanged(IConventionForeignKeyBuilder, IConventionContext<bool?>)
  ValueGenerationConvention.Dependencies
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Constructors

### NpgsqlValueGenerationConvention(ProviderConventionSetBuilderDependencies, RelationalConventionSetBuilderDependencies)

Creates a new instance of NpgsqlValueGenerationConvention.

    public NpgsqlValueGenerationConvention(ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies)

#### Parameters

`dependencies` ProviderConventionSetBuilderDependencies

  Parameter object containing dependencies for this convention.

`relationalDependencies` RelationalConventionSetBuilderDependencies

  Parameter object containing relational dependencies for this convention.

## Methods

### GetValueGenerated(IConventionProperty)

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

    protected override ValueGenerated? GetValueGenerated(IConventionProperty property)

#### Parameters

`property` IConventionProperty

  The property.

#### Returns

ValueGenerated?

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

### GetValueGenerated(IReadOnlyProperty, in StoreObjectIdentifier)

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

    public static ValueGenerated? GetValueGenerated(IReadOnlyProperty property, in StoreObjectIdentifier storeObject)

#### Parameters

`property` IReadOnlyProperty

  The property.

`storeObject` StoreObjectIdentifier

  The identifier of the store object.

#### Returns

ValueGenerated?

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

### ProcessPropertyAnnotationChanged(IConventionPropertyBuilder, string, IConventionAnnotation?, IConventionAnnotation?, IConventionContext<IConventionAnnotation>)

Called after an annotation is changed on a property.

    public override void ProcessPropertyAnnotationChanged(IConventionPropertyBuilder propertyBuilder, string name, IConventionAnnotation? annotation, IConventionAnnotation? oldAnnotation, IConventionContext<IConventionAnnotation> context)

#### Parameters

`propertyBuilder` IConventionPropertyBuilder

  The builder for the property.

`name` string

  The annotation name.

`annotation` IConventionAnnotation

  The new annotation.

`oldAnnotation` IConventionAnnotation

  The old annotation.

`context` IConventionContext<IConventionAnnotation>

  Additional information associated with convention execution.