public static void Initialize(IServiceProvider serviceProvider) { using (var context = new GrupoContext( serviceProvider.GetRequiredService < DbContextOptions <GrupoContext> >())) { if (context.Grupo.Any()) { return; // DB has been seeded } context.Grupo.AddRange( new Grupo { Codigo = 01, Descricao = "GRUPO DE VACINAS", Status = true }, new Grupo { Codigo = 40, Descricao = "GRUPO DE MEIAS", Status = false } ); context.SaveChanges(); } }
public GrupoesController(GrupoContext context) { _context = context; }