title: Entity Framework, table with 2 foreign keys to 2 different tables
body: <p>I have 3 models with fields in it like the following:</p>
  
  <pre><code>public class RootObject
  {
      [Key]
      public int RootObjectId { get; set; }
      [ForeignKey("RootObjectId")]
      public virtual AObject AObject { get; set; }
      [ForeignKey("RootObjectId")]
      public virtual BObject BObject { get; set; }
  
      public string Name { get; set; }
  }
  
  public class AObject
  {
      [Key]
      public int AObjectId { get; set; }
  
      //Other fields
  }
  
  public class BObject
  {
      [Key]
      public int BObjectId { get; set; }
  
      //Other fields
  }
  </code></pre>
  
  <p>I want it so that if I were to visually inspect the <code>RootObject</code> table I would see see a list of <code>RootObjectId</code>'s and <code>Name</code>'s.  For ease, lets assume even numbered <code>RootObjectId</code>'s are mapped to <code>AObjectId</code>'s and odds are mapped to <code>BObjectId</code>'s.  If I were to visually inspect <code>AObject</code>, I would expect to see the ID's 2, 4, 6, ... that are FK's for <code>RootObject</code>.  If were to visually inspect <code>BObject</code>, I would expect to see the ID's 1, 3, 5, ... that are FK's for <code>RootObject</code>.</p>
  
  <p>Currently, when I try this approach I get the following error:</p>
  
  <p>"An error occurred while updating the entries...Referential integrity constraint violations. A Dependent Role has multiple principals with different values."</p>
  
  <p>I tried to remove the FK attributes in <code>RootObject</code> but that created 2 additional columns in <code>RootObject</code> that were populated with ID numbers.  I don't want this since every <code>RootObject</code> has either one <code>AObject</code> or one <code>BObject</code>.  It can't have both.</p>