共用方式為


EntityType Element (CSDL)

The <EntityType> element is used by the Entity Data Model (EDM) in a conceptual schema definition language (CSDL) schema to specify an object in the domain of the application being designed. In the following syntax, a Department entity and its properties are declared and defined in an AdventureWorksHRModel namespace.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdventureWorksHRModel" Alias="Self" 
              xmlns="https://schemas.microsoft.com/ado/2006/04/edm">

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

The Department entity in this example identifies a Key property in the attribute assignment Key="DepartmentID". Other properties include Name, GroupName, and ModifiedDate. Each property has a data type and may include constraints.

The data types of properties in this CSDL syntax are mapped to properties in store schema definition language (SSDL) syntax that defines the storage layer. To understand the mapping, follow this data type through the parallel topics EntityType Element (SSDL) and EntityContainerMapping Element (MSL)

For more information about property types, attributes, and constraints, see Entity Data Model Types.

See Also

Concepts

EntityType Element (SSDL)
EntityTypeMapping Element (EntitySetMapping)
EntityContainerMapping Element (MSL)
Implementing Entities (EDM)
Implementing Associations (EDM)