Entity Framework - Many to many with shared foreign key
<p>I would like my Business and Customer tables to both reference the same Address table, so I created a many to many relationship table "EntityAddress"</p>

<p>My EntityAddress table has a EntityID field that I want the Business and Customer tables to share. However when I run my code below, my EntityAddress table has BusinessId and CustomerId fields that are auto-created.</p>

<p>Any idea why this is happening? Thanks!!</p>

<pre><code>builder.Entity&lt;EntityAddress&gt;().HasKey(x =&gt; new { x.EntityId, x.AddressId });
builder.Entity&lt;EntityAddress&gt;().HasOne(pc =&gt; pc.Address).WithMany(c =&gt; c.EntityAddresses).HasForeignKey(pc =&gt; pc.AddressId);
builder.Entity&lt;EntityAddress&gt;().HasOne(pc =&gt; pc.Business).WithMany(p =&gt; p.EntityAddresses).HasForeignKey(pc =&gt; pc.EntityId);
builder.Entity&lt;EntityAddress&gt;().HasOne(pc =&gt; pc.Customer).WithMany(p =&gt; p.EntityAddresses).HasForeignKey(pc =&gt; pc.EntityId);


public class Business
{
    [Key] public int Id { get; set; }
    public string Name { get; set; }
    public virtual ICollection&lt;EntityAddress&gt; EntityAddresses { get; set; }
}

public class Customer
{
    [Key] public int Id { get; set; }
    public string Name{ get; set; }
    public virtual ICollection&lt;EntityAddress&gt; EntityAddresses { get; set; }
}

public class EntityAddress
{
    [Key] public int Id { get; set; }
    public int EntityId { get; set; }
    public Enums.EntityType EntityType { get; set; }
    public int AddressId { get; set; }
    public virtual Address Address { get; set; }
    public virtual Business Business { get; set; }
    public virtual Customer Customer { get; set; }
}

public class Address
{
    [Key] public int Id { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zip { get; set; }
    public virtual ICollection&lt;EntityAddress&gt; EntityAddresses { get; set; }
}
</code></pre>