title: AddOrUpdate violates unique index
body: <p>I'm writing an MVC app in ASP.NET with the help of EF and I'm trying to seed my database. I have the following model:</p>
  
  <pre><code>public class Team
  {
      [ScaffoldColumn(false)]
      public int Id { get; set; }
  
      [ForeignKey("ParentTeam")]
      public int? ParentTeamId { get; set; }
  
      [Required(ErrorMessage = "Cannot create a Team without a name")]
      [Index(IsUnique = true)]
      [MaxLength(30)]
      public string Name { get; set; }
  
      public IEnumerable&lt;string&gt; Members { get; set; }
  
      public virtual Team ParentTeam { get; set; }
  
      public Team() { }
  
      public Team(string name)
      {
          Name = name;
      }
  }
  </code></pre>
  
  <p>My migration says:</p>
  
  <pre><code>var team = new Team("Admin");
  var team2 = new Team("Test Team");
  var team3 = new Team("Test Team 2");
  context.Teams.AddOrUpdate(t =&gt; t.Name, team, team2, team3);
  context.SaveChanges();
  </code></pre>
  
  <p>And then, when I run <code>Update-Database</code>, I get:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: Cannot insert duplicate key row in
    object 'dbo.Teams' with unique index 'IX_Name'. The duplicate key
    value is (Admin).</p>
  </blockquote>
  
  <p>It's a little confusing - I thought I told <code>AddOrUpdate</code> to identify rows to update by their names, but this does not happen. I cannot add <code>Name</code> to <code>Team</code>'s primary key, because it has a self-referencing foreign key (I could add <code>ParentTeamName</code> as a property, but I don't feel that it should be necessary). Am I misunderstanding the behaviour of <code>AddOrUpdate</code>? Did I specify the condition wrong?</p>