Share via


EntityContainer 元素 (CSDL)

使用概念性架构定义语言 (CSDL) 定义的 EntityContainer 是 实体数据模型 (EDM) 上生成的对象模型中的类规范。EntityContainer 控制定义的对象模型中的实体和关联的范围。这些实体和关联分别在架构中定义,然后作为 EntityContainer 定义内的 EntitySetAssociationSet 定义的成员。

在 XML 层次结构中,EntityContainer 元素独立于 Schema 元素,不过 EntityContainer 是在架构中定义的。这对于将 EntityContainer 映射到存储而言是至关重要的。概念性架构中的 EntityContainer 元素映射到存储元数据中对应的 EntityContainer 元素。请注意,在映射文件中,EntityContainer 的完全限定名称不包含架构命名空间名称。

有关映射 EntityContainer 的更多信息,请参见 EntityContainerMapping 元素 (MSL)

实体集和关联集

Adventure Works Human Resources 架构示例的 EntityContainer 为员工、部门、员工地址、员工历史记录等定义实体集。下面的示例以 CSDL 语法表示了定义为 AdventureWorksHRModel 命名空间的一部分的 HumanResourcesEntityContainer 的声明和定义。

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