Database Reference
In-Depth Information
Solution
Let's say that you have a model like the one shown in Figure
6-26
.
Figure 6-26.
A model for vehicles and tickets using an independent association
To change the association from an independent association to a foreign key association, do the following:
1.
Right-click the Ticket entity, and select Add
➤
Scalar Property. Rename the property
LicenseNumber.
2.
View the Mapping Details window for the association. Remove the mapping to the Ticket
table by selecting <Delete> from the Maps to Ticket control.
3.
Right-click the association, and view the properties. Click in the button in the Referential
Constraint control. In the dialog box, select the Vehicle entity in the Principal drop-down
control. The Principal Key and the Dependent Property should both be set to LicenseNumber,
as shown in Figure
6-27
.
Figure 6-27.
Creating the referential constraint for the foreign key association