语言

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

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

配置用于创建 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 默认值分配属性时,才会生成值(null对于 string、 0 for、 Guid.Empty for intGuid等)。

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

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

适用于

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

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

配置用于创建 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 默认值分配属性时,才会生成值(null对于 string、 0 for、 Guid.Empty for intGuid等)。

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

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

适用于

HasValueGenerator(Type)

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

配置 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 默认值分配属性时,才会生成值(null对于 string、 0 for、 Guid.Empty for intGuid等)。

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

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

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

适用于

HasValueGenerator<TGenerator>()

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

配置 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 默认值分配属性时,才会生成值(null对于 string、 0 for、 Guid.Empty for intGuid等)。

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

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

适用于