Share via


Mapping Element (MSL)

The Mapping element in mapping specification language (MSL) contains information for mapping objects that are defined in a conceptual model to a database (as described in a storage model). For more information, see CSDL Specification and SSDL Specification.

The Mapping element is the root element for a mapping specification. The XML namespace for mapping specifications is https://schemas.microsoft.com/ado/2008/09/mapping/cs.

The mapping element can have the following child elements (in the order listed):

Names of conceptual and storage model types that are referenced in MSL must be qualified by their respective namespace names. For information about the conceptual model namespace name, see Schema Element (CSDL). For information about the storage model namespace name, see Schema Element (SSDL). Aliases for namespaces that are used in MSL can be defined with the Alias element.

Applicable Attributes

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

Attribute Name Is Required Value

Space

Yes

C-S. This is a fixed value and cannot be changed.

Example

The following example shows a Mapping element that is based on part of the School model. For more information about the School model, see Quickstart:

<Mapping Space="C-S" 
         xmlns="https://schemas.microsoft.com/ado/2008/09/mapping/cs">
  <Alias Key="c" Value="SchoolModel"/>
  <EntityContainerMapping StorageEntityContainer="SchoolModelStoreContainer" 
                          CdmEntityContainer="SchoolModelEntities">
    <EntitySetMapping Name="Courses">
      <EntityTypeMapping TypeName="c.Course">
        <MappingFragment StoreEntitySet="Course">
          <ScalarProperty Name="CourseID" ColumnName="CourseID" />
          <ScalarProperty Name="Title" ColumnName="Title" />
          <ScalarProperty Name="Credits" ColumnName="Credits" />
          <ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name="Departments">
      <EntityTypeMapping TypeName="c.Department">
        <MappingFragment StoreEntitySet="Department">
          <ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
          <ScalarProperty Name="Name" ColumnName="Name" />
          <ScalarProperty Name="Budget" ColumnName="Budget" />
          <ScalarProperty Name="StartDate" ColumnName="StartDate" />
          <ScalarProperty Name="Administrator" ColumnName="Administrator" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
  </EntityContainerMapping>
</Mapping>

See Also

Concepts

EntityContainer Element (CSDL)
EntityContainer Element (SSDL)

Other Resources

Modeling and Mapping