SqlServerModelBuilderExtensions.HasValueGenerationStrategy 方法

定义

针对SQL Server时,为标记为 OnAdd的键属性配置默认值生成策略。

public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder HasValueGenerationStrategy (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder, Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder? HasValueGenerationStrategy (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder, Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false);
static member HasValueGenerationStrategy : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder * Nullable<Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy> * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder
<Extension()>
Public Function HasValueGenerationStrategy (modelBuilder As IConventionModelBuilder, valueGenerationStrategy As Nullable(Of SqlServerValueGenerationStrategy), Optional fromDataAnnotation As Boolean = false) As IConventionModelBuilder

参数

modelBuilder
IConventionModelBuilder

模型生成器。

valueGenerationStrategy
Nullable<SqlServerValueGenerationStrategy>

价值生成策略。

fromDataAnnotation
Boolean

指示配置是否是使用数据注释指定的。

返回

如果应用了配置,则为同一生成器实例, null 否则为 。

注解

有关详细信息和示例,请参阅为实体类型和关系建模和使用 EF Core 访问SQL Server和Azure SQL数据库

适用于