<docbook><section><title>VirtIngresAssociations</title><bridgehead class="http://www.w3.org/1999/xhtml:h3">Manually creating EDM Associations (FKs) for the Ingres Tutorial database</bridgehead>
<para>The following steps will detail what is required to manually create <emphasis>Associations</emphasis> in your Entity Data Model.</para><para>Before commencing the process, you will need to determine where these associations exist and their multiplicity (e.g., one-to-one, one-to-many, etc.).
 <emphasis><emphasis>NOTE:</emphasis> These steps will need to be repeated for each association.</emphasis></para><para>1.
 The first Association I will deal with is the relationship between <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders</span></emphasis> and <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_info</span></emphasis>, identified by the presence of the Scalar Property <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_no</span></emphasis> in both entities.
 This is a one-to-one relationship, as an entry in a customer order may only be associated with one customer&#39;s information.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc02.png" /></figure></para><para>2.
 To add the Association, right-click on the <emphasis>Customer</emphasis> entity.
 Then, click <emphasis>Add</emphasis> -&gt; <emphasis>Association</emphasis>.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc03.png" /></figure></para><para>3.
 You will now see the <emphasis>Add Association</emphasis> dialog.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc04.png" /></figure></para><para>4.
 Hit <emphasis>OK</emphasis>.
 The diagram will be refreshed to include the newly created association.</para><para>5.
 You now need to edit the mappings associated with the newly created association, so right-click the association on the diagram and select <emphasis>Table Mapping</emphasis> to display the <emphasis>Mapping Details</emphasis> pane.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc05.png" /></figure></para><para>6.
 Click the line that reads <emphasis>&lt;Add a Table or View&gt;</emphasis> to reveal a drop down list of all entities.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc06.png" /></figure></para><para>7.
 Here you need to select the entity on the right/far side of the association (the entity where the foreign key exists).
 In this example, it is the <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders</span></emphasis> entity.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc07.png" /></figure></para><para>8.
 The <emphasis>Mapping Details</emphasis> pane now refreshes to display both ends of the association.
 You will now be required to provide relevant target store data types in the <emphasis>Column</emphasis> column for the key fields, as depicted here.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc08.png" /></figure></para><para>9.
 Once the mapping is complete, you can build the project using <emphasis>Build</emphasis> -&gt; <emphasis>Build Solution</emphasis>.
 <emphasis><emphasis>NOTE:</emphasis> It is worthwhile to (re)build as each association is made, since the error messages can be a little confusing.</emphasis> <figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc09.png" /></figure></para><para>10.
 This should result in the following error, which is included here, since I (the author) found it misleading.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc10.png" /></figure> This error indicates that there are two sources — in this case, the <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders</span></emphasis> entity&#39;s Scalar Property <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_no</span></emphasis> and the Navigation Property <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_info</span></emphasis> in  — which are being mapped to the same target column — the Ingres column <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders.cust_no</span></emphasis> — which is not supported.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc11.png" /></figure></para><para>11.
 The solution is simple!  Delete the mapping for Scalar Property <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders.cust_no</span></emphasis>.
 Its only purpose is to hold data representing a relationship/association (it is a Foreign Key), which has already been represented by the newly-created association and resulting Navigation Property <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_no</span></emphasis>. Right-click on <emphasis><span style="color: red">
      UNKNOWN tag:
      http://www.w3.org/1999/xhtml:nowikicust_orders.cust_no</span></emphasis>.
 Then, click <emphasis>Delete</emphasis>.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc12.png" /></figure></para><para>12.
 The model diagram will refresh to reflect this change.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc14.png" /></figure></para><para>13.
 Build the project, again, using <emphasis>Build</emphasis> -&gt; <emphasis>Build Solution</emphasis>.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc09.png" /></figure></para><para>14.
 The project should now build fine.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc13.png" /></figure></para><para>You will need to repeat these steps for each association until you have a completed Entity Data Model.
<figure><graphic fileref="VirtIngresAssociations/VirtIngresAssc01.png" /></figure> </para></section></docbook>