PropertyBuilder.HasValueGenerator 方法

定义

重载

HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

将工厂配置为创建 , ValueGenerator 以用于为此属性生成值。

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

将工厂配置为创建 , ValueGenerator 以用于为此属性生成值。

HasValueGenerator(Type)

ValueGenerator配置将为此属性生成值的 。

HasValueGenerator<TGenerator>()

ValueGenerator配置将为此属性生成值的 。

HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

将工厂配置为创建 , ValueGenerator 以用于为此属性生成值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator (Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> factory);
abstract member HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGenerator (factory As Func(Of IProperty, IEntityType, ValueGenerator)) As PropertyBuilder

参数

factory
Func<IProperty,IEntityType,ValueGenerator>

将用于创建值生成器实例的委托。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

使用 (例如 )将实体添加到上下文时, Add<TEntity>(TEntity)会生成值。 仅当为 属性分配的 CLR 默认值 (nullstring时,才会为 、 0Guid.Empty for intGuid等 ) 生成值。

将调用此工厂一次以创建值生成器的单个实例,这将用于在实体类型的所有实例中为此属性生成值。

此方法适用于自定义值生成。 常见情况的值生成通常由数据库提供程序自动处理。

适用于

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

将工厂配置为创建 , ValueGenerator 以用于为此属性生成值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator (Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.ITypeBase,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> factory);
abstract member HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGenerator (factory As Func(Of IProperty, ITypeBase, ValueGenerator)) As PropertyBuilder

参数

factory
Func<IProperty,ITypeBase,ValueGenerator>

将用于创建值生成器实例的委托。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

使用 (例如 )将实体添加到上下文时, Add<TEntity>(TEntity)会生成值。 仅当为 属性分配的 CLR 默认值 (nullstring时,才会为 、 0Guid.Empty for intGuid等 ) 生成值。

将调用此工厂一次以创建值生成器的单个实例,这将用于在实体类型的所有实例中为此属性生成值。

此方法适用于自定义值生成。 常见情况的值生成通常由数据库提供程序自动处理。

适用于

HasValueGenerator(Type)

ValueGenerator配置将为此属性生成值的 。

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

参数

valueGeneratorType
Type

继承自 ValueGenerator的类型。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

使用 (例如 )将实体添加到上下文时, Add<TEntity>(TEntity)会生成值。 仅当为 属性分配的 CLR 默认值 (nullstring时,才会为 、 0Guid.Empty for intGuid等 ) 生成值。

将创建此类型的单个实例,并用于在实体类型的所有实例中生成此属性的值。 类型必须是可实例化且具有无参数构造函数。

此方法适用于自定义值生成。 常见情况的值生成通常由数据库提供程序自动处理。

设置 null 不会禁用此属性的值生成,它只是清除为此属性显式配置的任何生成器。 数据库提供程序可能仍具有属性类型的值生成器。

适用于

HasValueGenerator<TGenerator>()

ValueGenerator配置将为此属性生成值的 。

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

类型参数

TGenerator

继承自 ValueGenerator的类型。

返回

同一个生成器实例,以便可以链接多个配置调用。

注解

使用 (例如 )将实体添加到上下文时, Add<TEntity>(TEntity)会生成值。 仅当为 属性分配的 CLR 默认值 (nullstring时,才会为 、 0Guid.Empty for intGuid等 ) 生成值。

将创建此类型的单个实例,并用于在实体类型的所有实例中生成此属性的值。 类型必须是可实例化且具有无参数构造函数。

此方法适用于自定义值生成。 常见情况的值生成通常由数据库提供程序自动处理。

适用于