I am trying to seed a database using the context.AddOrUpdate
method, but the problem is that I need to make the inserted data unique based on a multi column index.<
You need to use anonymous type for specifying multiple columns. This also works without specifying the indicies.
context.ClimbingGrades.AddOrUpdate(grade => new { grade.Name, grade.GradeType },
new ClimbingGrade
{
Name = "5a",
Difficulty = 4.75,
GradeType = ClimbingGradeType.FontainebleauBloc
},
new ClimbingGrade
{
Name = "5a",
Difficulty = 4.25,
GradeType = ClimbingGradeType.FontainebleauTraverse
});