语言

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 可以改为用于单属性键,在这种情况下,行为是相同的。 如果使用这两个属性,则此属性优先。

有关详细信息和示例,请参阅 建模实体类型和关系 。

构造函数

名称 说明
PrimaryKeyAttribute(String, String[])

初始化 PrimaryKeyAttribute 类的新实例。

属性

名称 说明
PropertyNames

构成主键的属性,按顺序排列。

适用于