IConventionEntityTypeBuilder.HasKey 方法

定義

如果此實體類型不存在於指定的屬性上,請在模型中建立替代索引鍵。

public Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionKeyBuilder HasKey (System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> properties, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionKeyBuilder? HasKey (System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> properties, bool fromDataAnnotation = false);
abstract member HasKey : System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionKeyBuilder
Public Function HasKey (properties As IReadOnlyList(Of IConventionProperty), Optional fromDataAnnotation As Boolean = false) As IConventionKeyBuilder

參數

properties
IReadOnlyList<IConventionProperty>

組成索引鍵的屬性。

fromDataAnnotation
Boolean

指出是否使用資料批註來指定組態。

傳回

如果索引鍵存在於實體類型上,則可用來設定索引鍵的物件, null 否則為 。

適用於