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">
              <MappingFragment StoreEntitySet="Department">
                     Name="DepartmentID" ColumnName="DepartmentID" />
                <ScalarProperty Name="Name" ColumnName="Name" />
                <ScalarProperty Name="Budget" ColumnName="Budget" />
                     Name="StartDate" ColumnName="StartDate" />

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

              <MappingFragment StoreEntitySet="DeptEngineering">
                <ScalarProperty Name="DepartmentID" 
                                ColumnName="EngineeringDeptID" />
                <ScalarProperty Name="FiberOpticsBudget" 
                                ColumnName="FiberOpticsBudget" />
                <ScalarProperty Name="LabBudget" 
                                ColumnName="LabBudget" />


See Also

Community Additions