Share via


PrimitiveCollectionBuilder<TProperty>.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)

Source:
PrimitiveCollectionBuilder%60.cs
Source:
PrimitiveCollectionBuilder%60.cs

Configures the ValueGenerator that will generate values for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<TProperty> HasValueGenerator (Type? valueGeneratorType);
override this.HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<'Property>
Public Overridable Function HasValueGenerator (valueGeneratorType As Type) As PrimitiveCollectionBuilder(Of TProperty)

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>()

Source:
PrimitiveCollectionBuilder%60.cs
Source:
PrimitiveCollectionBuilder%60.cs

Configures the ValueGenerator that will generate values for this property.

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

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