Sdílet prostřednictvím


EntityContainer Element (CSDL)

The EntityContainer element in conceptual schema definition language (CSDL) is a logical container for entity sets, association sets, and function imports. A conceptual model entity container maps to a storage model entity container through the EntityContainerMapping element. A storage model entity container describes the structure of the database: entity sets describe tables, association sets describe foreign key constraints, and function imports describe stored procedures in a database. For more information, see EntityContainer Element (SSDL).

An EntityContainer element can have zero or one Documentation elements. If a Documentation element is present, it must precede all EntitySet, AssociationSet, and FunctionImport elements.

An EntityContainer element can have zero or more of the following child elements (in the order listed):

You can extend an EntityContainer element to include the contents of another EntityContainer that is within the same namespace. To include the contents of another EntityContainer, in the referencing EntityContainer element, set the value of the Extends attribute to the name of the EntityContainer element that you want to include. All child elements of the included EntityContainer element will be treated as child elements of the referencing EntityContainer element.

Applicable Attributes

The table below describes the attributes that can be applied to the Using element.

Attribute Name Is Required Value

Name

Yes

The name of the entity container.

Extends

No

The name of another entity container within the same namespace. (For more information about namespaces, see Schema Element (CSDL).)

Note

Any number of annotation attributes (custom XML attributes) may be applied to the EntityContainer element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The following example shows an EntityContainer element that defines three entity sets and two association sets.

<EntityContainer Name="BooksContainer" >
  <EntitySet Name="Books" EntityType="BooksModel.Book" />
  <EntitySet Name="Publishers" EntityType="BooksModel.Publisher" />
  <EntitySet Name="Authors" EntityType="BooksModel.Author" />
  <AssociationSet Name="PublishedBy" Association="BooksModel.PublishedBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Publisher" EntitySet="Publishers" />
  </AssociationSet>
  <AssociationSet Name="WrittenBy" Association="BooksModel.WrittenBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Author" EntitySet="Authors" />
  </AssociationSet>
</EntityContainer>

See Also

Concepts

Entity Framework Overview
CSDL Specification
Schema Element (CSDL)

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools
entity container (Entity Data Model)