public static void EnsurePopulated(IApplicationBuilder application) { MovieDBContext context = application.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <MovieDBContext>(); //make sure the database is up to date with any migrations if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } //Save changes to the database context.SaveChanges(); }
//Constructor public EFMovieRepository(MovieDBContext context) { _context = context; }