<docbook><section><title>VirtProgressAssociations</title><bridgehead class="http://www.w3.org/1999/xhtml:h3">Manually creating EDM Associations (FKs) for the Progress isports database</bridgehead>
<para>The following steps will detail what is required to manually create <emphasis>Associations</emphasis> in your Entity Data Model.</para><para>You will need to determine where these associations exist and their multiplicity (one-to-one, one-to-many, etc.) before commencing with the following steps.
 <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>Customer</emphasis> and <emphasis>Invoice</emphasis>, identified by the presence of the scalar property <emphasis>Cust_Num</emphasis> in both entities.
 This is a one-to-many relationship, as a Customer may have any number of Invoices.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs01.png" /></figure></para><para>2.
 To add the Association, right click on the <emphasis>Customer</emphasis> entity, then <emphasis>Add</emphasis> -&gt; <emphasis>Association</emphasis>.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs02.png" /></figure></para><para>3.
 You will now see the <emphasis>Add Association</emphasis> dialog.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs03.png" /></figure></para><para>4.
 For this association, the only thing that needs changing is the default name assigned to the <emphasis>Navigation Property</emphasis>.
 Change the default from <emphasis>Invoice</emphasis> to <emphasis>invoices</emphasis> on the <emphasis>Customer</emphasis> end of the association.This better reflects the multiplicity of the association such that a Customer is associated with zero or many Invoices (plural).
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs04.png" /></figure>Typically, here is where you will -</para><itemizedlist mark="bullet" spacing="compact"><listitem> Select the entity at each end of the association </listitem>
<listitem> Select the multiplicity of each end of the association, and </listitem>
<listitem> Provide suitable names for the association and its navigation properties</listitem>
</itemizedlist><para>5.
 Hit <emphasis>OK</emphasis>.
 The diagram will be refreshed to include the newly created association.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs05.png" /></figure></para><para>6.
 You now need to edit the mappings associated with the newly created association, so right-click the association on the diagram.
 Then, select <emphasis>Table Mapping</emphasis> to display the <emphasis>Mapping Details</emphasis> pane.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs06.png" /></figure></para><para>7.
 Click the line which reads <emphasis>&lt;Add a Table or View&gt;</emphasis> to reveal a drop down list of all entities.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs07.png" /></figure></para><para>8.
 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>Invoice</emphasis> entity.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs08.png" /></figure></para><para>9.
 The <emphasis>Mapping Details</emphasis> pane now refreshes to display both ends of the association.
 Now, you must provide relevant target store data types in the <emphasis>Column</emphasis> column for the key fields, as depicted here.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs09.png" /></figure> <figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs10.png" /></figure> <figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs11.png" /></figure></para><para>10.
 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 building as each association is made, since the error messages can be a little confusing.</emphasis> <figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs12.png" /></figure></para><para>11.
 This should result in the following error, which is included here since I (the author) found it misleading.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs13.png" /></figure> This error indicates that there are two source columns — in this case, the Invoice entity&#39;s Scalar Property <emphasis>Cust_Num</emphasis> and Navigation Property <emphasis>Customer</emphasis> — which are both mapped to the same target column — the Progress column <emphasis>Invoice.Cust_Num</emphasis> — and this is not supported.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs14.png" /></figure></para><para>12.
 The solution is simple! Simply delete the mapping of the Scalar Property <emphasis>Invoice.Cust_Num</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>Customer</emphasis>. Right click on <emphasis>Invoice.Cust_Num</emphasis> then <emphasis>Delete</emphasis>.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs15.png" /></figure></para><para>13.
 The model diagram will refresh to reflect this change.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs16.png" /></figure></para><para>14.
 Build the project, again, using <emphasis>Build</emphasis> -&gt; <emphasis>Build Solution</emphasis>.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs12.png" /></figure></para><para>15.
 The project should now build fine.
<figure><graphic fileref="VirtProgressAssociations/ProgressEDMFKs17.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="VirtProgressAssociations/ProgressEDMFKs18.png" /></figure> </para></section></docbook>