共用方式為


EntityType 項目 (SSDL)

存放結構定義語言 (SSDL) 內的 EntityType 項目表示基礎資料庫之資料表或檢視中的資料列。SSDL 中的 EntitySet 項目表示資料列發生所在的資料表或檢視。EntitySet 項目的 EntityType 屬性會指定表示 SSDL 實體集中之資料列的特定 SSDL 實體類型。SSDL 實體類型和 CSDL 實體類型間的對應是在 EntityTypeMapping 項目中指定的。

EntityType 項目可以擁有下列子項目 (依列出的順序):

適用屬性

以下資料表描述可套用至 EntityType 項目的屬性。

屬性名稱

必要

Name

實體類型的名稱。此值通常與資料表名稱相同,在資料表中實體類型表示資料列。此值不可以包含句號 (.)。

注意

可以將任何數量的附註屬性 (自訂 XML 屬性) 套用至 EntityType 項目。不過,自訂屬性不可屬於任何 XML 命名空間,這是保留供 SSDL 使用。任兩個自訂屬性的完整名稱不能相同。

範例

下列範例示範具有兩個屬性的 EntityType 項目。

<EntityType Name="Customers">
  <Documentation>
    <Summary>Summary here.</Summary>
    <LongDescription>Long description here.</LongDescription>
  </Documentation>
  <Key>
    <PropertyRef Name="CustomerId" />
  </Key>
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>
<EntityType Name="Customers">
  <Documentation>
    <Summary>Summary here.</Summary>
    <LongDescription>Long description here.</LongDescription>
  </Documentation>
  <Key>
    <PropertyRef Name="CustomerId" />
  </Key>
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>

<EntityType Name="Customers">
  <Documentation>
    <Summary>Summary here.</Summary>
    <LongDescription>Long description here.</LongDescription>
  </Documentation>
  <Key>
    <PropertyRef Name="CustomerId" />
  </Key>
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>

請參閱

概念

Entity Framework 概觀

SSDL 規格

其他資源

CSDL、SSDL 和 MSL 規格

ADO.NET Entity Data Model Tools