Export (0) Print
Expand All

How to: Define a Model with Multiple Entity Sets per Type

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The topic describes how to create a conceptual model with multiple entity sets per type (MEST). Defining multiple entity sets per type allows you to streamline your code when multiple tables in the underlying database have the same structure. When you are working with entity types that do not have associations to other types, defining a MEST model is straightforward. However, to define a MEST model for entity types that do have associations with other types, you must implement MEST for each type in the object graph. For more information, see MEST - What is it and how does it work? This topic describes how to define a MEST model for an entity type that does not have associations with other types.

Note that you should only implement MEST when the underlying database tables have the same structure.

The basic steps for defining a MEST model are as follows:

  1. Use multiple EntitySet elements (each with the same value for the EntityType attribute) to define multiple entity sets for a given type in the conceptual model.

  2. Map each entity set to the appropriate table in the mapping specification language (MSL). For more information, see EntitySetMapping Element (MSL).

The example below assumes that you have installed the following sample database:

The example also assumes that you have configured your project to use the Entity Framework. For more information, see Configuring the Entity Framework.

To create the storage model

  1. Add the following XML file to your project and name it MEST.ssdl.

    -OR-

    Add an empty .edmx file (MEST.edmx) to your project and replace the Schema element under the edmx:StorageModels element with the Schema element in the following XML file. For more information, see How to: Create a New .edmx File and .edmx File Overview.

    Note that the tables in the storage model have the same structure.

To create the conceptual model

  1. Add the following XML file to your project and name it MEST.csdl.

    -OR-

    In your .edmx file, replace the Schema element in the edmx:ConceptualModels element with the Schema element in the following XML file.

    Note that two entity sets have been defined for the Course entity type.

To define the mapping between the conceptual model and the storage model

  1. Add the following XML file to your project and name it MEST.msl.

    -OR-

    In your .edmx file, replace the Mapping element in the edmx:Mappings element with the Mapping element in the following XML file.

    Note that each entity set is mapped to the appropriate underlying database.

See Also

Show:
© 2014 Microsoft