title: Entity Framework Core 3.0 - Creating a self-referencing many to many relationship
body: <p>So here is my issue...what I am trying to create is a self-referencing many to many relationship.  Basically here is my model.</p>
  
  <pre><code>public class InformationSystem
  {
    public InformationSystem()
    {
       Systems = new HashSet&lt;InformationSystem&gt;();
       ParentSystems = new HashSet&lt;InformationSystem&gt;();
    }
   [Key()]
   public int InformationSystemID { get; set; }
   public string InformationSystemName { get; set; }
   //Navigation properties
   public virtual ICollection&lt;InformationSystem&gt; Systems { get; set; }
   public virtual ICollection&lt;InformationSystem&gt; ParentSystems { get; set; }
  }
  </code></pre>
  
  <p>The idea being that a system can have many parents and a parent can have many children.  I know how to do a self-referencing entity where many children can have one parent.  What is tripping me up is the many to many part.  Below is my DbContext.</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
    modelBuilder.Entity&lt;InformationSystem&gt;(entity =&gt;
    {
      entity
         .HasMany(e =&gt; e.ParentSystems)
         .WithMany(e =&gt; e.Systems)
         .OnDelete(DeleteBehavior.Restrict);
    });
  </code></pre>
  
  <p>However on my DbContext, I get an error that .WithMany does not contain a definition for with many that would accept an input of type collection.  I know that basically what needs to be built is a link table when the code first creates a migration and updates the database.  The link table I think would have two columns and no key.  One column would be InformationSystemID and one would be ParentInformationSystemID.  Both would be foreign keys.  I also know that for this to work right, the delete behavior should be restrict so that if an entry is deleted or updated in the link table, that change won't cascade (and create a loop).  Can someone please point me in the right direction of what I need to do to get EF Core 3 to do this correctly?  If I had to create a link table myself, how would I go about doing that?  And what would I need to do in my DbContext?  I know that a link table would look something like this:<br>
  I'd greatly appreciate it. </p>
  
  <pre><code>public class InfoSysToParentInfoSys
  {
    public int InfoSysID;
    public virtual InformationSystem InfoSys;
  
    public int ParentInfoSysID;
    public virtual InformationSystem ParentInfoSys;
  }
  </code></pre>