Compartir a través de


EntitySetMapping Element (MSL)

Defining an object model using the Entity Data Model (EDM) requires both programmable classes and storage structures to contain data for applications built on the model. The EntitySetMapping element in mapping specification language (MSL) connects an EntitySet defined in conceptual schema definition language (CSDL) to an EntitySet in store schema definition language (SSDL).

The EntityContainer elements in the conceptual schema are mapped to corresponding EntityContainer elements in the storage metadata. In the mapping file, the fully qualified name of the EntityContainer does not include the schema namespace name. The use of an entity container name qualified by a schema namespace name causes a mapping exception.

The EntitySetMapping element maps the Department entity in the conceptual schema to the Department table in the store metadata. An EntitySet is an aggregate of instances of an entity type, and the EntitySetMapping is defined by the EntityType mappings that connects type names and properties from the AdventureWorksHRModel to the table names and column names in the storage metadata. For more information about this syntax, see EntityTypeMapping Element (EntitySetMapping).

The following example shows the EntitySet mapping specification for the Department entity. In this example, the EntitySetMapping element is used inside the EntityContainerMapping element that specifies mapping between the HumanResources container in the AdventureWorksHRModel conceptual schema and the HumanResources container in the AdventureWorksHRTarget storage metadata.

<EntityContainerMapping CdmEntityContainer="HumanResources"
                      StorageEntityContainer="HumanResources">

    <EntitySetMapping Name="Department">
      <EntityTypeMapping
                TypeName="AdventureWorksHRModel.Department">
        <TableMappingFragment TableName="Department">
          <ScalarProperty Name="DepartmentID"
                             ColumnName="DepartmentID" />
          <ScalarProperty Name="Name" ColumnName="Name" />
          <ScalarProperty Name="GroupName"
                                     ColumnName="GroupName" />
          <ScalarProperty Name="ModifiedDate"
                                  ColumnName="ModifiedDate" />
        </TableMappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>

  </EntityContainerMapping>

See Also

Concepts

EntityTypeMapping Element (EntitySetMapping)
EntityContainer Element (SSDL)
EntityContainer Element (CSDL)
AdventureWorks Complete Model (EDM)