EF 5 AddOrUpdate Duplicates data
问题 This is the code in the Seed method: var city = new City { Name = "A" }; var nh = new List<Neigh> { new Neigh { City = city, Name = "N1" }, new Neigh { City = city, Name = "N2" }, new Neigh { City = city, Name = "N3" }, //new Neigh { City = city, Name = "N4" }, }; context.Neighs.AddOrUpdate( p => p.Name, nh.ToArray() ); After running update-database everything works as expected. I can run it multiple times without problem. However if at some point I uncomment the fourth neighborhood and run