Поделиться через


Key Attribute (EntityType SSDL)

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

The following declaration of the Department entity in the Adventure Works metadata 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="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>

See Also

Concepts

Key Attribute (EntityType CSDL)
AdventureWorks Complete Model (EDM)