EntityType 元素 (CSDL)

<EntityType> 元素由 实体数据模型 (EDM) 在概念性架构定义语言 (CSDL) 架构中用于指定设计的应用程序域中的对象。在下面的语法中,在 AdventureWorksHRModel 命名空间中声明并定义 Department 实体及其属性。

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

本示例中的 Department 实体标识属性 (Attribute) 赋值 Key="DepartmentID" 中的 Key 属性 (Property)。其他属性包括 NameGroupNameModifiedDate。每个属性都有数据类型并可能包含约束。

此 CSDL 语法中的属性的数据类型映射到定义存储层的存储架构定义语言 (SSDL) 语法中的属性。若要了解该映射,请通过并行主题 EntityType 元素 (SSDL)EntityContainerMapping 元素 (MSL) 跟踪此数据类型。

有关属性 (Property) 类型、属性 (Attribute) 和约束的更多信息,请参见 实体数据模型类型

另请参见

概念

EntityType 元素 (SSDL)
EntityTypeMapping 元素 (EntitySetMapping)
EntityContainerMapping 元素 (MSL)
实现实体 (EDM)
实现关联 (EDM)