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(); } }
public EFCategoryRepository(CategoryDbContext context) { this.context = context; }