I have a list of type User
and when I try to seed my db to reflect updates, it is simply adding all the entries again. I will share my code I am executing in my Seed()
method. I wish to just update the records (but keep the add functionality), if they already exist. Any thoughts?
List<User> users = new List<User>();
users.Add(new User { FirstName = "Dee", LastName = "Reynolds" });
users.Add(new User { FirstName = "Rickety", LastName = "Cricket" });
users.ForEach(b => context.Users.AddOrUpdate(b));