Delen via


PropertyBuilder.HasValueGeneratorFactory Method

Definition

Overloads

HasValueGeneratorFactory(Type)

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

HasValueGeneratorFactory<TFactory>()

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

HasValueGeneratorFactory(Type)

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGeneratorFactory (Type? valueGeneratorFactoryType);
abstract member HasValueGeneratorFactory : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGeneratorFactory : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGeneratorFactory (valueGeneratorFactoryType As Type) As PropertyBuilder

Parameters

valueGeneratorFactoryType
Type

A type that inherits from ValueGeneratorFactory.

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

HasValueGeneratorFactory<TFactory>()

Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs
Source:
PropertyBuilder.cs

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGeneratorFactory<TFactory> () where TFactory : Microsoft.EntityFrameworkCore.ValueGeneration.ValueGeneratorFactory;
abstract member HasValueGeneratorFactory : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Factory :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGeneratorFactory)
override this.HasValueGeneratorFactory : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Factory :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGeneratorFactory)
Public Overridable Function HasValueGeneratorFactory(Of TFactory As ValueGeneratorFactory) () As PropertyBuilder

Type Parameters

TFactory

A type that inherits from ValueGeneratorFactory.

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