Share via


PrimitiveCollectionBuilder.HasValueGenerator Method

Definition

Overloads

HasValueGenerator(Type)

Configures the ValueGenerator that will generate values for this property.

HasValueGenerator<TGenerator>()

Configures the ValueGenerator that will generate values for this property.

HasValueGenerator(Type)

Configures the ValueGenerator that will generate values for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasValueGenerator (Type? valueGeneratorType);
abstract member HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder
override this.HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder
Public Overridable Function HasValueGenerator (valueGeneratorType As Type) As PrimitiveCollectionBuilder

Parameters

valueGeneratorType
Type

A type that inherits from ValueGenerator.

Returns

The same builder instance so that multiple configuration calls can be chained.

Remarks

Values are generated when the entity is added to the context using, for example, Add<TEntity>(TEntity). Values are generated only when the property is assigned the CLR default value (null for string, 0 for int, Guid.Empty for Guid, etc.).

A single instance of this type will be created and used to generate values for this property in all instances of the entity type. The type must be instantiable and have a parameterless constructor.

This method is intended for use with custom value generation. Value generation for common cases is usually handled automatically by the database provider.

Setting null does not disable value generation for this property, it just clears any generator explicitly configured for this property. The database provider may still have a value generator for the property type.

Applies to

HasValueGenerator<TGenerator>()

Configures the ValueGenerator that will generate values for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasValueGenerator<TGenerator> () where TGenerator : Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator;
abstract member HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
override this.HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
Public Overridable Function HasValueGenerator(Of TGenerator As ValueGenerator) () As PrimitiveCollectionBuilder

Type Parameters

TGenerator

A type that inherits from ValueGenerator.

Returns

The same builder instance so that multiple configuration calls can be chained.

Remarks

Values are generated when the entity is added to the context using, for example, Add<TEntity>(TEntity). Values are generated only when the property is assigned the CLR default value (null for string, 0 for int, Guid.Empty for Guid, etc.).

A single instance of this type will be created and used to generate values for this property in all instances of the entity type. The type must be instantiable and have a parameterless constructor.

This method is intended for use with custom value generation. Value generation for common cases is usually handled automatically by the database provider.

Applies to