title: Entity Framework - Multiple tables referencing to one table
body: <p>I came here with an Entity Framework problem which I'm struggling with for some time already. Let's describe it quickly. I have 2 models that are referencing to one model... and I don't really know how can I create the relationship with EF annotations.</p>
  
  <p>First model:</p>
  
  <pre><code>public class ProcessedLog
  {
      [Key]
      public int Id { get; set; }
  
      // Some other data
  
      public virtual LogLocation Location { get; set; }
  }
  </code></pre>
  
  <p>Second model:</p>
  
  <pre><code>public class QueuedLog
  {
      [Key]
      public int Id { get; set; }
  
      // Some other data
  
      public virtual LogLocation Location { get; set; }
  }
  </code></pre>
  
  <p>And the model that I'm referencing to:</p>
  
  <pre><code>public class LogLocation
  {
      [Key]
      public int Id { get; set; }
  
      [ForeignKey("QueuedLog")]
      public int QueuedLogId { get; set; }
  
      [ForeignKey("ProcessedLog")]
      public int ProcessedLogId { get; set; }
  
      // Some other data
  
      public virtual QueuedLog QueuedLog { get; set; }
      public virtual ProcessedLog ProcessedLog { get; set; }
  }
  </code></pre>
  
  <p>As you can see, I've already tried to do something but it's not working properly. I'm getting an error:</p>
  
  <blockquote>
    <p>LogLocation_ProcessedLog_Source: : Multiplicity is not valid in Role 'LogLocation_ProcessedLog_Source' in relationship 'LogLocation_ProcessedLog'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '<em>'.
    LogLocation_QueuedLog_Source: : Multiplicity is not valid in Role 'LogLocation_QueuedLog_Source' in relationship 'LogLocation_QueuedLog'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '</em>'.</p>
  </blockquote>
  
  <p>It works only when I do typical one-to-one relationship - but this is not what i want.</p>
  
  <p>Btw. this is my first post at StackOverflow so i would like to say hi to everyone! :) You're creating a great community, thanks for all your work!</p>
  
  <p><strong>Edit</strong>
  The question is: how can i create these models and relationshiph so it would work like this:</p>
  
  <p>I add new ProcessedLog to Db -> It adds a new LogLocation with ProcessedLogId equal to the related ProcessedLog and the QueuedLogId is NULL.</p>