PrimaryKeyAttribute 類別

定義

為對應至這個 CLR 類型的實體類型指定主鍵。

[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class PrimaryKeyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type PrimaryKeyAttribute = class
    inherit Attribute
Public NotInheritable Class PrimaryKeyAttribute
Inherits Attribute
繼承
PrimaryKeyAttribute
屬性

備註

這個屬性可用於由單一屬性組成的索引鍵,以及由多個屬性組成的複合索引鍵。 KeyAttribute 可以改為用於單一屬性索引鍵,在此情況下行為完全相同。 如果使用這兩個屬性,則此屬性會優先使用。

如需詳細資訊和範例,請參閱 模型化實體類型和關聯 性。

建構函式

PrimaryKeyAttribute(String, String[])

初始化 PrimaryKeyAttribute 類別的新執行個體。

屬性

PropertyNames

依序構成主鍵的屬性。

適用於