共用方式為


Key 屬性 (EntityType CSDL)

在 實體資料模型 (EDM) 中,EntityType 項目的 Key 屬性 (Attribute) 會指定將用來識別所有作業中之型別執行個體的屬性 (Property)。

下列 Department 實體宣告會顯示 Key 指派:Key="Department ID"

此案例中的 Property 定義是一個十六位元整數。Key 屬性不能為 null,如同限制式指派 Nullable="false" 所指示。

  <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)