public static void Populate(IApplicationBuilder app, IHostingEnvironment env) { PetContext _ctx = app.ApplicationServices.GetRequiredService <PetContext>(); if (!_ctx.PetTypes.Any()) { _ctx.PetTypes.AddRange( new PetType { Name = "Dog", Breeds = GetBreeds <Breed>("dogs.json", env) }, new PetType { Name = "Cat", Breeds = GetBreeds <Breed>("cats.json", env) } ); _ctx.SaveChanges(); } }
public PetRepository(PetContext repo) { _repo = repo; }