Ejemplo n.º 1
0
        public static void EnsurePopulated(IApplicationBuilder application)
        {
            MovieDBContext context = application.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <MovieDBContext>();

            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
            }

            if (!context.Entries.Any())
            {
                context.Entries.AddRange(
                    new EntryResponse
                {
                    Category = "Seed",
                    Title    = "Seed Data",
                    Year     = 1997,
                    Director = "Rachel Morey",
                    Rating   = "G",
                    Edited   = false,
                    LentTo   = "Seed Data",
                    Notes    = "Seed Data"
                });

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public EFMovieRepository(MovieDBContext context)
 {
     _context = context;
 }