次の方法で共有


EntityContainer 要素 (CSDL)

概念スキーマ定義言語 (CSDL) で定義された EntityContainer は、エンティティ データ モデル (EDM) 上に構築されたオブジェクト モデルのクラスのスキーマです。EntityContainer は、定義するオブジェクト モデルのエンティティとアソシエーションのスコープを制御します。これらのエンティティとアソシエーションは、スキーマ内で個々に定義された後、EntityContainer 定義内の EntitySet および AssociationSet 定義のメンバとして定義されます。

XML 階層では、スキーマに EntityContainer が定義されている場合でも、EntityContainer 要素は Schema 要素から独立しています。これは、EntityContainer をストレージにマッピングするうえで重要なことです。概念スキーマ内の EntityContainer 要素は、ストレージ メタデータ内で対応する EntityContainer 要素にマッピングされます。マッピング ファイルでは、EntityContainer の完全修飾名にスキーマの名前空間の名前が含まれないことに注意してください。

EntityContainer のマッピングの詳細については、「EntityContainerMapping 要素 (MSL)」を参照してください。

エンティティ セットとアソシエーション セット

Adventure Works Human Resources スキーマ例の EntityContainer は、従業員、部門、従業員の住所、従業員の履歴などのエンティティ セットを定義します。次の例には、AdventureWorksHRModel 名前空間の一部として定義されている HumanResourcesEntityContainer の CSDL 構文の宣言および定義が含まれています。

  <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 Complete Model (EDM)