title: EF many to many one way add same item twice to child collection doesn't get saved
body: <p>Thx for taking the time to read this. I've been looking for an answer to this problem for a week already and I'm running out of ideas...
  This is the scenario:</p>
  
  <p>The model:</p>
  
  <pre><code>public class Parent{
      public Guid Id {get;set;}
      public virtual ICollection&lt;Child&gt; ChildCollection{ get; set; }
  }
  
  public class Child {
      public Guid Id {get;set;}
      public string Name{get;set}
  }
  </code></pre>
  
  <p>On Model creating:</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;Parent&gt;()
              .HasMany(c =&gt; c.ChildCollection)
              .WithMany()
              .Map(x =&gt;
              {
                  x.ToTable("ParentToChildMapping");
                  x.MapLeftKey("ParentId");
                  x.MapRightKey("ChildId");
              }); 
  }
  </code></pre>
  
  <p>Now the problem:</p>
  
  <p>If I have a Parent object with a Child object in the collection and try to add a new object of same id to the child collection the DbContext doesn't "detect" the change and doesn't add a new entry in the mapping table.
  But if I add a new Child (that doesn't exist in the collection) it does get added ok.</p>
  
  <p>For Example:</p>
  
  <pre><code>{  
     var childId = Guid.Parse("cbd5bccc-b977-4861-870d-089994958cdf");
     var parent = new Parent { ChildCollection = new HashSet&lt;Child&gt;() };
     var context = new DBContext();
     var child = context.Childs.Single(c=&gt;c.Id=childId);
  
     parent.ChildCollection.Add(child);
     context.Parents.Add(parent);
     context.SaveChanges();
  }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>{
     var childId = Guid.Parse("cbd5bccc-b977-4861-870d-089994958cdf");
     var context = new DBContext();
     var parent = dbContext.Parents.Include(p=&gt;p.ChildCollection).Single(p=&gt;p.Id=parentId); // The id saved in the point before.
     var child = context.Childs.Single(c=&gt;c.Id=childId);
  
     parent.ChildCollection.Add(child);
     // At this point parent.ChildCollection.Count() = 2
     context.SaveChanges();
  }       
  </code></pre>
  
  <p>The count of the collection is 2, which is fine. But save changes doesn't add the item. If I retrieve it back from the db using context again, it only returns 1 element in the collection.</p>
  
  <p>Any thoughts are wellcome.</p>