Database Reference
In-Depth Information
6.
Repeat step 5, but this time set the Toyota as the derived entity.
7.
Right-click the CarDealer entity and select Delete. When prompted to delete the CarDealer
table from the store model, select No.
8.
Right-click the design surface, and select Add Association. Name the association
CarDealer. Select Dealer on the left with a multiplicity of one. Select Car on the right
with a multiplicity of many. Name the navigation property on the Car side Dealer. Name
the navigation property on the Dealer side Cars. Be sure to uncheck the Add foreign key
properties.
9.
Select the association, and view the Mapping Details window. Select CarDealer in the
Add a Table or View drop-down menu. Make sure that the DealerId property maps to the
DealerId column, and the CarId property maps to the CarId column.
Right-click the .edmx file, and select Open With XML Editor. Edit the mapping section with the changes shown
in Listing 6-35 for the BMW and Toyota entities.
Listing 6-35. Mapping the BMW and Toyota Tables
<EntitySetMapping Name="Cars">
<EntityTypeMapping TypeName="IsTypeOf(EFRecipesModel.BMW)">
<MappingFragment StoreEntitySet="BMW">
<ScalarProperty Name="CollisionAvoidance"
ColumnName="CollisionAvoidance" />
<ScalarProperty Name="CarId" ColumnName="CarId"/>
<ScalarProperty Name="Model" ColumnName="Model"/>
<ScalarProperty Name="Year" ColumnName="Year"/>
<ScalarProperty Name="Color" ColumnName="Color"/>
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(EFRecipesModel.Toyota)">
<MappingFragment StoreEntitySet="Toyota">
<ScalarProperty Name="CarId" ColumnName="CarId"/>
<ScalarProperty Name="Model" ColumnName="Model"/>
<ScalarProperty Name="Year" ColumnName="Year"/>
<ScalarProperty Name="Color" ColumnName="Color"/>
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
The resulting model is shown in Figure 6-19 .
 
Search WWH ::




Custom Search