ConventionEntityTypeExtensions.SetPrimaryKey 方法

定义

设置此实体类型的主键。

public static Microsoft.EntityFrameworkCore.Metadata.IConventionKey SetPrimaryKey (this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property, bool fromDataAnnotation = false);
static member SetPrimaryKey : Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * Microsoft.EntityFrameworkCore.Metadata.IConventionProperty * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionKey
<Extension()>
Public Function SetPrimaryKey (entityType As IConventionEntityType, property As IConventionProperty, Optional fromDataAnnotation As Boolean = false) As IConventionKey

参数

entityType
IConventionEntityType

要设置键的实体类型。

property
IConventionProperty

主键属性。

fromDataAnnotation
Boolean

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

返回

新创建的密钥。

适用于