title: How do i assign 2 values from different tables into 1 variable name as foreign key using Entity Framework-Code First
body: <p>I'm confused with the foreign key concept. I'm trying to arrange the key relationships in each database class according to the Code First concept in Entity Framework. </p>
  
  <p>I have 3 tables: a, b and c. </p>
  
  <p>Table a has <code>aId</code> as primary key(PK), table b has <code>bId</code> as PK, table c has <code>cId</code> as primary key. The relationship between table is:</p>
  
  <ul>
  <li>a-b : many-to-one, </li>
  <li>a-c : one-to-one, </li>
  <li>b-c : one-to-many</li>
  </ul>
  
  <p>Table a has a variable refid which can hold both bId or cId values. </p>
  
  <pre><code>&lt;ForeignKey("bId")&gt;
  Public Property refid As b
  
  &lt;ForeignKey("cId")&gt;
  Public Property refid As c
  </code></pre>
  
  <p>refid is now highlighted red saying that </p>
  
  <blockquote>
    <p>the properties cannot overload each other because they differ only by
    return types.</p>
  </blockquote>
  
  <p>What am i doing wrong?</p>
  
  <p><strong>EDITED</strong></p>
  
  <pre><code>public class a
  
      public property aId as String  // Primary key
  
      Public Property refid As String
  
      &lt;ForeignKey("refid")&gt;
      Public Property b As b
  
      &lt;ForeignKey("refid")&gt;
      Public Property c As c
  
  End Class
  
  
  public class b
  
      public property bId as String    // Primary key
  
      // b Navigation Property
      public property aCol As ICollection(Of a)
  
  End Class
  
  
  public class c
  
      public property cId as String  // Primary key
  
      // c Navigation Property
      public property aCol As ICollection(Of a)
  
  End Class
  </code></pre>