title: EF: Create/Remove relation from Many-to-Many relations when `AutoDetectChangesEnabled` and `ProxyCreationEnabled` are disabled on DbContext
body: <ol>
  <li><p>Knowning <code>Foo.Id</code> and <code>Bar.Id</code> how can I create their relation without loading the entities from the DB.</p>
  
  <pre><code>class Foo {
      public int Id { get; set; }
      public Lst&lt;Bar&gt; Bars { get; set; }
  }
  
  class Bar {
      public int Id { get; set; }
      public Lst&lt;Foo&gt; Foos { get; set; }
  }
  </code></pre>
  
  <p>Also this configuration are disabled in <code>DbContext</code> constructor:</p>
  
  <pre><code>Configuration.AutoDetectChangesEnabled = false;
  Configuration.ProxyCreationEnabled = false;
  Configuration.LazyLoadingEnabled = false;
  </code></pre></li>
  <li><p>And how it is possible to remove the relationship?</p></li>
  </ol>
  
  <hr>
  
  <p>Example:</p>
  
  <pre><code>using (var ctx = new DbCtx())
  {
      ctx.Configuration.LazyLoadingEnabled = false;
      ctx.Configuration.ProxyCreationEnabled = false;
      ctx.Configuration.AutoDetectChangesEnabled = false;
      ctx.Database.Log += Console.WriteLine;
  
      var foo = new Foo {Id = 1, Bars = new List&lt;Bar&gt;() };
      var bar = new Bar { Id = 3, Foos = new List&lt;Foo&gt;() };
  
      // This approach wont work, as AutoDetectChanges are disabled
      ctx.Foos.Attach(foo);
      ctx.Bars.Attach(bar);
  
      foo.Bars.Add(bar);
      ctx.SaveChanges();
  }
  </code></pre>
  
  <p>How can I define relation here, without changing the configuration. </p>
  
  <p>Thank you in advance.</p>