Compartir a través de


EntityTypeMapping Element (EntitySetMapping)

In the Entity Data Model (EDM), an EntityTypeMapping element connects an entity type and each of its properties, as declared in conceptual schema definition language (CSDL), to a table and column in the metadata defined in store schema definition language (SSDL). The EntityTypeMapping elements are used inside EntitySetMapping and EntityContainer elements.

The following example shows the EntityTypeMapping in isolation:

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

This mapping connects the Department entity in the AdventureWorksHRModel namespace to the Department TableName inside the MappingFragment elements. The EntityContainer elements in the conceptual schema are mapped to corresponding EntityContainer elements in the storage metadata, but in the mapping file, the fully qualified name of the EntityContainer does not include the schema namespace name. In the XML hierarchy, EntityContainer is independent of Schema.

Each of the properties of the Department entity are connected to ColumnName objects specified inside ScalarProperty elements.

In full context, the EntityTypeMapping is contained by Mapping, EntityContainerMapping, and EntitySetMapping elements.

<Mapping>
  <EntityContainerMapping CdmEntityContainer="HumanResources"
StorageEntityContainer="HumanResources">
    <EntitySetMapping Name="Department">

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

    </EntitySetMapping>

  </EntityContainerMapping>
</Mapping>

For the CSDL syntax in which the Department entity is declared, see EntityType Element (CSDL). For the SSDL syntax describing the storage model being mapped, see EntityType Element (SSDL).

See Also

Concepts

Mapping Element (MSL)
EntityContainerMapping Element (MSL)
EntitySetMapping Element (MSL)
EntityType Element (CSDL)
EntityType Element (SSDL)
AdventureWorks Complete Model (EDM)