title: EF Core 3.1 how to automap in Many-to-many relationship
body: <p>I have constructed a database model in .NET Core Entity framework with a DB first approach. I have several Many-to-many relationships in my database, and they are all represented with a joining table. </p>
  
  <p>Like so: </p>
  
  <pre><code>public partial class Test1
  {
      public Test1()
      {
          Test1_Test2= new HashSet&lt;Test1_Test2&gt;();
      }
  
      public int Id { get; set; }
      ..
  
      public virtual ICollection&lt;Test1_Test2&gt; Test1_Test2{ get; set; }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public partial class Test2
  {
      public Test2()
      {
          Test1_Test2= new HashSet&lt;Test1_Test2&gt;();
      }
  
      public int Id { get; set; }
      ..
  
      public virtual ICollection&lt;Test1_Test2&gt; Test1_Test2{ get; set; }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public partial class Test1_Test2
  {
      public int Test1Id{ get; set; }
      public int Test2Id{ get; set; }
  
      public virtual Test1 Test1{ get; set; }
      public virtual Test2 Test2{ get; set; }
  }
  </code></pre>
  
  <p>EF have constructed a Fluent API that supports this structure, with foreign keys and composite primary key in the joining table. </p>
  
  <p>When I am to add something into this relationship, it is sort of a tedious operation, where I have to do something along the lines of this, in order to correctly populate my joining table:</p>
  
  <pre><code>_context.Test1.Add(Test1);
  _context.Test2.Add(Test2);
  Test1_Test2.Test1 = Test1;
  Test1_Test2.Test2 = Test2;
  _context.Test1_Test2.Add(Test1_Test2);
  _context.SaveChanges();
  </code></pre>
  
  <p>From the old EF in .NET Framework, I remember that it was sort of straight forward to do an automapper functionality which would make me able to only do the following: </p>
  
  <pre><code>Test1.Test2 = Test2; 
  _context.Test1.Add(Test1);
  _context.SaveChanges();
  </code></pre>
  
  <p>This is convenient as EF figures out how populate the joining table automatically. Also this is much more convenient when I have to make requests from these tables.</p>
  
  <p>Therefore, how do I add an "automapper" functionality in .Net Core EF DB first - Is this even supported? </p>