title: 2 Tables sharing a relation table in Entity Framework 4.1 (Code-First) mapping advice?
body: <p>Is it possible to create a mapping from 2 tables and have them share a link table? I am not sure if this would work, but there may be a better way to do this and wanted to get some advice. Here is my idea for the mappings:</p>
  
  <pre><code>//For Attachments
  HasOptional(a =&gt; a.Subscription).WithMany().Map(m =&gt; {m.MapLeftKey("SubscriptionID"); m.MapRightKey("EntityId"); m.ToTable("Subscriptions);});
  
  //For Submittals
  HasOptional(s =&gt; s.Subscription).WithMany().Map(m =&gt; {m.MapLeftKey("SubscriptionID"); m.MapRightKey("EntityId"); m.ToTable("Subscriptions);});
  </code></pre>
  
  <p>Will this create the one link table for both entities to share? Is this a good approach or should I have a FKs for each entity in a subscription table?</p>
  
  <p>Update: I don't think those mappings will work since it is a many-to-one? This may be more appropriate:</p>
  
  <pre><code>HasOptional(s =&gt; s.Subscription).WithMany().Map(m =&gt; {m.MapKey("EntityId"); m.ToTable("Subscriptions");});
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bfXLH.jpg" alt="Model Example"></p>