Exemplo n.º 1
0
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            EscolhaRestauranteDbContext context = app.ApplicationServices
                                                  .GetRequiredService <EscolhaRestauranteDbContext>();

            context.Database.Migrate();
            if (!context.Votos.Any())
            {
                context.Votos.AddRange(
                    new Voto
                {
                    Nome        = "Felipe",
                    Email       = "*****@*****.**",
                    DataVoto    = DateTime.Now,
                    Restaurante = new Restaurante {
                        Nome = "Palatu's"
                    }
                },
                    new Voto
                {
                    Nome        = "José",
                    Email       = "*****@*****.**",
                    DataVoto    = DateTime.Now,
                    Restaurante = new Restaurante {
                        Nome = "Panorama"
                    }
                });
                context.SaveChanges();
            }
        }
 public EFEscolhaRestauranteRepository(EscolhaRestauranteDbContext ctx)
 {
     context = ctx;
 }