Key 属性 (EntityType CSDL)

实体数据模型 (EDM) 中,EntityType 元素的 Key 属性指定用于在所有操作中标识该类型的实体的属性。

以下 Department 实体的声明显示了 Key 赋值:Key="Department ID"

此处的 Property 定义为十六位整数。如约束赋值 Nullable="false" 所指示,Key 属性不能为 null。

  <EntityType Name="Department" 
   <Key>
        <PropertyRef Name="DepartmentID">
    </Key>
    <Property Name="DepartmentID" Type="Int16" Nullable="false" />
    <Property Name="Name" Type="String" Nullable="false" />
    <Property Name="GroupName" Type="String" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

另请参见

概念

Key 属性 (EntityType SSDL)