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

            context.Database.Migrate();

            if (!context.Categories.Any())
            {
                context.Categories.AddRange(
                    new Category {
                    CategoryId = Guid.NewGuid(), Name = "Memoria RAM", Active = true
                },
                    new Category {
                    CategoryId = Guid.NewGuid(), Name = "Discos Duros", Active = true
                },
                    new Category {
                    CategoryId = Guid.NewGuid(), Name = "Monitores", Active = true
                },
                    new Category {
                    CategoryId = Guid.NewGuid(), Name = "Accesorios", Active = true
                },
                    new Category {
                    CategoryId = Guid.NewGuid(), Name = "Limpieza", Active = true
                }
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public EFCategoryRepository(CategoryDbContext context)
 {
     this.context = context;
 }