title: Entity Framework Code First AddOrUpdate method insert Duplicate values
body: <p>I have simple entity:</p>
  
  <pre><code>public class Hall
  {
      [Key]
      public int Id {get; set;}
  
      public string Name [get; set;}
  }
  </code></pre>
  
  <p>Then in the <code>Seed</code> method I use <code>AddOrUpdate</code> to populate table:</p>
  
  <pre><code>var hall1 = new Hall { Name = "French" };
  var hall2 = new Hall { Name = "German" };
  var hall3 = new Hall { Name = "Japanese" };
  
  context.Halls.AddOrUpdate(
      h =&gt; h.Name,
      hall1,
      hall2,
      hall3
  );
  </code></pre>
  
  <p>Then I run in the Package Management Console:</p>
  
  <pre><code>Add-Migration Current
  Update-Database
  </code></pre>
  
  <p>It's all fine: I have three rows in the table "Hall". But if I run in the Package Management Console <code>Update-Database</code> again I have already five rows:</p>
  
  <pre><code>Id  Name
  1   French
  2   Japaneese
  3   German
  4   French
  5   Japanese
  </code></pre>
  
  <p>Why? I think it is should be three rows again, not five. I tried to use <code>Id</code> property instead of <code>Name</code> but it does not make the difference.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This code produces the same result:</p>
  
  <pre><code>var hall1 = new Hall { Id = 1, Name = "French" };
  var hall2 = new Hall { Id = 2, Name = "German" };
  var hall3 = new Hall { Id = 3, Name = "Japanese" };
  
  context.Halls.AddOrUpdate(
                  h =&gt; h.Id,
                  hall1);
  
  context.Halls.AddOrUpdate(
                  h =&gt; h.Id,
                  hall2);
  
  context.Halls.AddOrUpdate(
                  h =&gt; h.Id,
                  hall3);
  </code></pre>
  
  <p>Also I have the latest EntityFramework installed via nuget.</p>