Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Abstract Type (EntityTypeMapping)

.NET Framework 3.5

In the Entity Data Model (EDM), mapping specification language (MSL) can only map an abstract EntityType, as defined with its attribute Abstract="true", by using the keyword IsTypeOf.

In table-per-type inheritance a mapping fragment for an abstract entity is required. In table-per-hierarchy inheritance, mapping the abstract type is optional, and if mapped, table-per-heirarchy mapping does not assign a discriminator property.

In the case of an abstract type without derived concrete types, the mapping loader throws an error if the abstract type is mapped.

The following mapping schema shows how to map an abstract type using table-per-type inheritance based on the conceptual schema in Abstract Type (EntityType Element CSDL).

The following syntax maps the abstract type Department and derived types DeptBusiness and DeptEngineering. The mapping syntax is the same as mapping a derived type, except for the keyword IsTypeOf, which is optional for derived types.

          <!-- Mapping for table-per-type inheritance-->
          <EntitySetMapping Name="Departments">
            <EntityTypeMapping 
                     TypeName="IsTypeOf(SchoolDataLib.Department)">
              <MappingFragment StoreEntitySet="Department">
                <ScalarProperty 
                     Name="DepartmentID" ColumnName="DepartmentID" />
                <ScalarProperty Name="Name" ColumnName="Name" />
                <ScalarProperty Name="Budget" ColumnName="Budget" />
                <ScalarProperty 
                     Name="StartDate" ColumnName="StartDate" />
              </MappingFragment>
            </EntityTypeMapping>

            <EntityTypeMapping TypeName="SchoolDataLib.DeptBusiness">
              <MappingFragment StoreEntitySet="DeptBusiness">
                <ScalarProperty Name="DepartmentID" 
                                ColumnName="BusinessDeptID" />
                <ScalarProperty Name="AccountingBudget" 
                                ColumnName="AccountingBudget" />
                <ScalarProperty Name="LegalBudget" 
                                ColumnName="LegalBudget" />
              </MappingFragment>
            </EntityTypeMapping>

            <EntityTypeMapping
                       TypeName="SchoolDataLib.DeptEngineering">
              <MappingFragment StoreEntitySet="DeptEngineering">
                <ScalarProperty Name="DepartmentID" 
                                ColumnName="EngineeringDeptID" />
                <ScalarProperty Name="FiberOpticsBudget" 
                                ColumnName="FiberOpticsBudget" />
                <ScalarProperty Name="LabBudget" 
                                ColumnName="LabBudget" />
              </MappingFragment>
            </EntityTypeMapping>

        </EntitySetMapping>

See Also

Community Additions

Show:
© 2015 Microsoft