EntityContainer 項目 (CSDL)

使用概念結構定義語言 (CSDL) 所定義的 EntityContainer 是 實體資料模型 (EDM) 上建置之物件模型內的類別規格。EntityContainer 會控制所定義之物件模型內實體和關聯的範圍。這些實體和關聯會個別定義在結構描述中,然後當做 EntitySetAssociationSet 定義的成員置於 EntityContainer 定義中。

在 XML 階層中,EntityContainer 項目與 Schema 項目分開,即使 EntityContainer 定義在結構描述內亦然。將 EntityContainer 對應到儲存區時,這是非常重要的一點。概念結構描述中的 EntityContainer 項目會對應到儲存中繼資料內的對應 EntityContainer 項目。請注意在對應檔中,EntityContainer 的完整名稱不包含結構描述命名空間名稱。

如需對應 EntityContainer 的詳細資訊,請參閱 EntityContainerMapping 項目 (MSL)

實體集和關聯集

Adventure Works Human Resources 結構描述範例的 EntityContainer 會定義員工、部門、員工地址、員工過去歷史等內容的實體集。下列範例包含 HumanResourcesEntityContainer 之 CSDL 語法內的宣告和定義 (定義為 AdventureWorksHRModel 命名空間的一部分)。

  <EntityContainer Name="HumanResources">
    <EntitySet Name="Department" EntityType="Self.Department" />
    <EntitySet Name="Employee" EntityType="Self.Employee" />
    <EntitySet Name="EmployeeAddress" EntityType="Self.EmployeeAddress" />
    <EntitySet Name="EmployeeDepartmentHistory"
                      EntityType="Self.EmployeeDepartmentHistory" />
    <EntitySet Name="EmployeePayHistory"
                             EntityType="Self.EmployeePayHistory" />
    <EntitySet Name="JobCandidate" EntityType="Self.JobCandidate" />
    <EntitySet Name="Shift" EntityType="Self.Shift" />
    <AssociationSet Name="Employee_Employee_ManagerID"
                     Association="Self.Employee_Employee_ManagerID">
      <End Role="Employee" EntitySet="Employee" />
      <End Role="EmployeeManager" EntitySet="Employee" />
    </AssociationSet>
    <AssociationSet Name="JobCandidate_Employee_EmployeeID"
                Association="Self.JobCandidate_Employee_EmployeeID">
      <End Role="Employee" EntitySet="Employee" />
      <End Role="JobCandidate" EntitySet="JobCandidate" />
    </AssociationSet>
  </EntityContainer>

如需這個 EntityContainer 中所定義之實體集和關聯集的詳細資訊,請參閱本章節的以下主題:

Name 屬性 (EntityContainer CSDL)

EntitySet 項目 (EntityContainer CSDL)

AssociationSet 項目 (EntityContainer CSDL)

另請參閱

概念

Name 屬性 (EntityContainer CSDL)
實體集 (EDM)
關聯集 (EDM)
EntityContainerMapping 項目 (MSL)
AdventureWorks 完整模型 (EDM)