Condividi tramite


Attributo Key (EntityType CSDL)

In Entity Data Model (EDM) l'attributo Key di un elemento EntityType specifica la proprietà che verrà utilizzata per identificare le istanze del tipo in tutte le operazioni.

La dichiarazione seguente dell'entità Department illustra l'assegnazione di Key: Key="Department ID".

La definizione di Property, in questo caso, è un numero intero a sedici bit. La proprietà Key non può essere null, come indicato dall'assegnazione del vincolo 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>

Vedere anche

Concetti

Attributo Key (EntityType SSDL)