public static void EnsurePopulated(IApplicationBuilder application) { MovieDBContext context = application.ApplicationServices. CreateScope().ServiceProvider.GetRequiredService <MovieDBContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Movies.Any()) { context.Movies.AddRange( new Movie { Title = "Tenet", Category = "Action/Adventure", Year = 2020, Director = "Christopher Nolan", Rating = "G", Edited = "n/a", Notes = "n/a", Lent = "n/a" } ); context.SaveChanges(); } }
public EFMovieRepository(MovieDBContext context) { _context = context; }