EntitySetMapping Element (MSL)

The EntitySetMapping element in mapping specification language (MSL) maps all types in a conceptual model entity set to entity sets in the storage model. An entity set in the conceptual model is a logical container for instances of entities of the same type (and derived types). An entity set in the storage model represents a table or view in the underlying database. The conceptual model entity set is specified by the value of the Name attribute of the EntitySetMapping element. The mapped-to table or view is specified by the StoreEntitySet attribute in each child MappingFragment element or in the EntitySetMapping element itself.

The EntitySetMapping element can have the following child elements:

Applicable Attributes

The following table describes the attributes that can be applied to the EntitySetMapping element.

Attribute Name Is Required Value

Name

Yes

The name of the conceptual model entity set that is being mapped.

TypeName1

No

The name of the conceptual model entity type that is being mapped.

StoreEntitySet1

No

The name of the storage model entity set that is being mapped to.

MakeColumnsDistinct

No

True or False depending on whether only distinct rows are returned.

If this attribute is set to True, the GenerateUpdateViews attribute of the EntityContainerMapping element must be set to False.

1 The TypeName and StoreEntitySet attributes can be used in place of the EntityTypeMapping and MappingFragment child elements to map a single entity type to a single table.

Example

The following example shows an EntitySetMapping element that maps three types (a base type and two derived types) in the Courses entity set of the conceptual model to three different tables in the underlying database. The tables are specified by the StoreEntitySet attribute in each MappingFragment element.

<EntitySetMapping Name="Courses">
  <EntityTypeMapping TypeName="IsTypeOf(SchoolModel1.Course)">
    <MappingFragment StoreEntitySet="Course">
      <ScalarProperty Name="CourseID" ColumnName="CourseID" />
      <ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
      <ScalarProperty Name="Credits" ColumnName="Credits" />
      <ScalarProperty Name="Title" ColumnName="Title" />
    </MappingFragment>
  </EntityTypeMapping>
  <EntityTypeMapping TypeName="IsTypeOf(SchoolModel1.OnlineCourse)">
    <MappingFragment StoreEntitySet="OnlineCourse">
      <ScalarProperty Name="CourseID" ColumnName="CourseID" />
      <ScalarProperty Name="URL" ColumnName="URL" />
    </MappingFragment>
  </EntityTypeMapping>
  <EntityTypeMapping TypeName="IsTypeOf(SchoolModel1.OnsiteCourse)">
    <MappingFragment StoreEntitySet="OnsiteCourse">
      <ScalarProperty Name="CourseID" ColumnName="CourseID" />
      <ScalarProperty Name="Time" ColumnName="Time" />
      <ScalarProperty Name="Days" ColumnName="Days" />
      <ScalarProperty Name="Location" ColumnName="Location" />
    </MappingFragment>
  </EntityTypeMapping>
</EntitySetMapping>

See Also

Concepts

CSDL Specification
SSDL Specification

Other Resources

Modeling and Mapping