EntityContainer Element (CSDL)

An EntityContainer defined in conceptual schema definition language (CSDL) is the specification for a class in an object model built on the Entity Data Model (EDM). The EntityContainer controls the scope of entities and associations in the object model being defined. Those entities and associations are defined in schemas individually and then as members of EntitySet and AssociationSet definitions inside an EntityContainer definition.

In the XML hierarchy, the EntityContainer element is separate from the Schema element even though the EntityContainer is defined in a schema. This is important in mapping the EntityContainer to storage. The EntityContainer elements in the conceptual schema are mapped to corresponding EntityContainer elements in the storage metadata. Note that in the mapping file, the fully qualified name of the EntityContainer does not include the schema namespace name.

For more information about mapping the EntityContainer, see EntityContainerMapping Element (MSL).

Entity and Association Sets

The EntityContainer for the Adventure Works Human Resources schema example defines entity sets for employees, departments, employee addresses, employee histories, and so forth. The following example includes the declarations and definitions in CSDL syntax for the HumanResources EntityContainer defined as part of the AdventureWorksHRModel namespace.

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

For more information about the entity sets and association sets defined in this EntityContainer, see the following topics in this section:

Name Attribute (EntityContainer CSDL)

Extends Attribute (EntityContainer CSDL)

EntitySet Element (EntityContainer CSDL)

AssociationSet Element (EntityContainer CSDL)

See Also

Concepts

Name Attribute (EntityContainer CSDL)
Entity Sets (EDM)
Association Sets (EDM)
EntityContainerMapping Element (MSL)
AdventureWorks Complete Model (EDM)