Key 属性 (EntityType SSDL)
实体数据模型 (EDM) 中,EntityType 定义的 Key 属性 (Attribute) 指定用于标识所有操作中的类型实例的属性 (Property)。
Adventure Works 元数据中的以下 Department 实体声明显示 Key 赋值:Key="Department ID"
。
此处的 Property 定义为十六位整数。如约束赋值 Nullable="false"
所指示,Key 属性不能为 null。
<EntityType Name="Department">
<Key>
<PropertyRef Name="DepartmentID">
</Key>
<Property Name="DepartmentID" Type="smallint" Nullable="false"
StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="GroupName" Type="nvarchar" Nullable="false"
MaxLength="50" />
<Property Name="ModifiedDate" Type="datetime" Nullable="false" />
</EntityType>