public static void Seed(ConsultantContext context) { context.Database.EnsureCreated(); if (context.consultants.Any()) { return; // DB has been seeded } List <Competence> newCompetences = CreateFakeToDatabaseCompetences(); context.competences.AddRange(newCompetences); context.SaveChanges(); List <Consultant> newConsultants = CreateFakeToDatabaseConsultants(); context.consultants.AddRange(newConsultants); context.SaveChanges(); List <ConsultantCompetence> newCompetenceConsultants = CreateFakeToDatabaseCompetenceConsultant(newCompetences, newConsultants); context.ConsultantCompetences.AddRange(newCompetenceConsultants); context.SaveChanges(); }
public ConsultantRepository(ConsultantContext context) { this.context = context; }