title: Strange behavior of Entity Framework
body: <p>I have this model class:</p>
  
  <pre><code>public class User
  {
      public int Id { get; set; }
      public string Name { get; set; }
  
      public virtual ICollection&lt;User&gt; Collection1 { get; set; } = new List&lt;User&gt;();
      public virtual ICollection&lt;User&gt; Collection2 { get; set; } = new List&lt;User&gt;();
  }
  </code></pre>
  
  <p>Then I add a few records in the database:</p>
  
  <pre><code>var context = new UsersContext();
  
  var user1 = new User();
  var user2 = new User();
  var user3 = new User();
  
  user1.Name = "user1";
  user2.Name = "user2";
  user3.Name = "user3";
  
  user1.Collection1.Add(user2);
  user2.Collection1.Add(user3);
  
  context.Users.Add(user1);
  context.Users.Add(user2);
  context.Users.Add(user3);
  
  context.SaveChanges();
  </code></pre>
  
  <p>Then I run this query:</p>
  
  <pre><code>var user2 = context.Users.First(user =&gt; user.Name == "user2");
  
  foreach (var u in user2.Collection2)
      Console.WriteLine($"{user2.Name}  Collection2 {u.Name}");
  </code></pre>
  
  <p>And I get:</p>
  
  <blockquote>
    <p>user2 Collection2 user1</p>
  </blockquote>
  
  <p>Why in <code>Collection2</code> do I have a record? And how to fix it ?</p>
  
  <p><strong>UPDATE.</strong></p>
  
  <p><a href="https://i.stack.imgur.com/lX9Ur.png" rel="nofollow"><img src="https://i.stack.imgur.com/lX9Ur.png" alt="enter image description here"></a></p>
  
  <p>This is a link to the test project <a href="https://drive.google.com/file/d/0BxP-1gZwSGL5S1c4cWN1Q2NsYVU/view" rel="nofollow">https://drive.google.com/file/d/0BxP-1gZwSGL5S1c4cWN1Q2NsYVU/view</a></p>