Delen via


entity container (Entity Data Model)

An entity container is a logical grouping of entity sets, association sets, and function imports.

The following must be true of an entity container defined in a conceptual model:

  • At least one entity container must be defined in each conceptual model.

  • The entity container must have a unique name within each conceptual model.

An entity container can define entity sets or association sets that use entity types or associations defined in one or more namespaces. For more information, see Entity Data Model: Namespaces.

Example

The diagram below shows a conceptual model with three entity types: Book, Publisher, and Author. See the next example for more information.

Ee382821.ExampleModel(en-us,VS.100).gif

Although the diagram does not convey entity container information, the conceptual model must define an entity container. The ADO.NET Entity Framework uses a DSL called conceptual schema definition language (CSDL) to define conceptual models. The following CSDL defines an entity container for the conceptual model shown in the diagram above. Note that the entity container name is defined in an XML attribute.

<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 Data Model Key Concepts

Entity Data Model