void AddOrUpdateInstructor(AchieveContext context, string courseTitle, string instructorName) { var crs = context.Courses.SingleOrDefault(c => c.CourseName == courseTitle); var inst = crs.Instructors.SingleOrDefault(i => i.LastName == instructorName); if (inst == null) { crs.Instructors.Add(context.Instructors.Single(i => i.LastName == instructorName)); } }