示例#1
0
        public static void EnsurePopulated(IApplicationBuilder application)
        {
            Assignment3DbContext context = application.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <Assignment3DbContext>();

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

            //if (!context.Movies.Any())
            //{
            //    context.Movies.AddRange(
            //        new ApplicationResponse
            //        {
            //            MovieId = 1,
            //            Category = "Action/Adventure",
            //            Title = "Avengers, The",
            //            Year = 2012,
            //            Director = "Joss Whedon",
            //            Rating = "PG-13",
            //            Edited = false,
            //            LentTo = "",
            //            Notes = "",

            //        }
            //    );

            //    context.SaveChanges();
            //}
        }
 public HomeController(ILogger <HomeController> logger, Assignment3DbContext moviesdb)
 {
     _logger   = logger;
     _moviesdb = moviesdb;
 }
 public MoviesController(Assignment3DbContext context)
 {
     _context = context;
 }