Partager via


Key Attribute (EntityType CSDL)

In the Entity Data Model (EDM), the Key attribute of an EntityType element specifies the property that will be used to identify instances of the type in all operations.

The following declaration of the Department entity shows the Key assignment: Key="Department ID".

The Property definition in this case is a sixteen-bit integer. The Key property cannot be null, as indicated by the constraint assignment 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>

See Also

Concepts

Key Attribute (EntityType SSDL)