Key 元素 (SSDL)
以存储架构定义语言 (SSDL) 表示的 Key 元素表示基础数据库中某个表的主键。 Key 是 EntityType 元素的一个子元素,表示表中的一行。 主键是通过引用在 EntityType 元素上定义的一个或多个 Property 元素在 Key 元素中定义的。
Key 元素可以具有以下子元素(按所列顺序):
PropertyRef(一个或多个)
没有适用于 Key 元素的特性。
示例
下面的示例演示具有引用一个属性的键的 EntityType 元素:
<EntityType Name="Customers">
<Documentation>
<Summary>Summary here.</Summary>
<LongDescription>Long description here.</LongDescription>
</Documentation>
<Key>
<PropertyRef Name="CustomerId" />
</Key>
<Property Name="CustomerId" Type="int" Nullable="false" />
<Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>