title: SQL Server 2008 Express - Got "The columns do not match an existing primary key or UNIQUE constraint" despite constraints being set
body: <p>I have the following tables</p>
  
  <pre><code>ModuleClass ( &lt;ModuleID&gt;, &lt;Section&gt;, &lt;Number&gt;, StartDate, EndDate)
  ClassEnrollment ( &lt;ModuleID&gt;, &lt;Section&gt;, &lt;Term Code&gt;, &lt;User Name&gt;, Role)
  </code></pre>
  
  <p>Now a ModuleClass entity can have more than one enrollment, so there is a 1 to M relationship. However, when attempting to define FK between ModuleClass and ClassEnrollment using ModuleID and Section, I get</p>
  
  <blockquote>
    <p>The columns in table ClassEnrollment do
    not match an existing primary key or
    UNIQUE constraint</p>
  </blockquote>
  
  <p>However, both ModuleID and Section are participating in a PK constraint. </p>
  
  <p>(I am using the Visual Database Tools to create the tables and specify the relationship).</p>
  
  <p>What is a better way of representing this relationship?</p>