語言

PrimaryKeyAttribute 類別

定義

指定映射到此 CLR 類型的實體類型的主鍵。

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

備註

此屬性可用於由單一屬性組成的鍵,以及由多個屬性組成的複合鍵。 KeyAttribute 也可以用於單一屬性鍵,此時行為相同。 若同時使用兩個屬性,則該屬性優先。

更多資訊與範例請參閱 建模實體類型與關係 。

建構函式

名稱 Description
PrimaryKeyAttribute(String, String[])

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

屬性

名稱 Description
PropertyNames

構成主鍵的屬性,依序排列。

適用於