title: Is it possible to have multiple collection properties of entities with the same base class (TPH) inside one entity?
body: <p>In my project I use Entity Framework core 2.0.
  The next code is slightly simplified. There are such models:</p>
  
  <pre><code>public class Site
  {
      public int Id { get; set; } 
      public string Name { get; set; }
      public ICollection&lt;AudioLink&gt; AudioLinks { get; set; }
      public ICollection&lt;VideoLink&gt; VideoLinks { get; set; }
  }
  
  public abstract class Link
  {
      public int Id { get; set; }         
      public string Href { get; set; }
  
      public int SiteId { get; set; }
      public Site Site { get; set; }
  }
  
  public class AudioLink : Link
  {
  }
  
  public class VideoLink : Link
  {
  }
  </code></pre>
  
  <p>I use Fluent API to configure relationships:</p>
  
  <pre><code>public class AppDbContext : DbContext
  {
      public AppDbContext(DbContextOptions&lt;AppDbContext&gt; options) : base(options)
      {
      }
  
      public DbSet&lt;Site&gt; Sites { get; set; }
      public DbSet&lt;AudioLink&gt; AudioLinks { get; set; }
      public DbSet&lt;VideoLink&gt; VideoLinks { get; set; }
  
      protected override void OnModelCreating(ModelBuilder builder)
      {
          builder.Entity&lt;Link&gt;()
              .HasDiscriminator&lt;byte&gt;("LinkType")
              .HasValue&lt;AudioLink&gt;(1)
              .HasValue&lt;VideoLink&gt;(2);
  
          builder.Entity&lt;Site &gt;().HasMany(s =&gt; s.VideoLinks)
              .WithOne(l =&gt; l.Site)
              .HasForeignKey(l =&gt; l.SiteId);
  
          builder.Entity&lt;Site &gt;().HasMany(s =&gt; s.AudioLinks)
              .WithOne(l =&gt; l.Site)
              .HasForeignKey(l =&gt; l.SiteId);
      }
  }
  </code></pre>
  
  <p>It look's like the migration and database are created correctly.
  But when I create new Site object:</p>
  
  <pre><code>var site = new Site(){Id = 1, Name = "SiteA"}
  var audioLink = new AudioLink(){Id = 1, Href = "abc", Site = site};
  
  context.Sites.Add(site);
  context.SaveChanges();
  context.AudioLinks.Add(audioLink);// exception occurs
  context.SaveChanges();
  </code></pre>
  
  <p>the next exception is thrown "Unable to cast object of type 'ApplicationCore.Entities.AudioLink' to type 'ApplicationCore.Entities.VideoLink'."<br/>
  Could you tell what am I doing wrong?</p>