Esempio n. 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new LDSMoviesContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <LDSMoviesContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "The Other Side of Heaven",
                    ReleaseDate = DateTime.Parse("2002-04-12"),
                    Genre       = "Missionary Drama",
                    Price       = 7.99M,
                    Rating      = "PG"
                },

                    new Movie
                {
                    Title       = "The Cokeville Miracle ",
                    ReleaseDate = DateTime.Parse("2015-06-05"),
                    Genre       = "Drama",
                    Price       = 8.99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "The R.M.",
                    ReleaseDate = DateTime.Parse("2003-01-31"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "PG"
                },

                    new Movie
                {
                    Title       = "The Singles Ward",
                    ReleaseDate = DateTime.Parse("2002-01-30"),
                    Genre       = "Comedy",
                    Price       = 3.99M,
                    Rating      = "PG"
                }
                    );
                context.SaveChanges();
            }
        }
Esempio n. 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new LDSMoviesContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <LDSMoviesContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Rating      = "R",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Rating      = "PG-13",
                    Price       = 8.99M
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Rating      = "PG-13",
                    Price       = 9.99M
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Rating      = "PG-13",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
Esempio n. 3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new LDSMoviesContext(
                       serviceProvider.GetRequiredService <DbContextOptions <LDSMoviesContext> >()))
            {
                // Look for any movies.
                if (context.movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.movie.AddRange(
                    new movie
                {
                    Title       = "Pride and Prejudice",
                    ReleaseDate = DateTime.Parse("2003-12-05"),
                    Genre       = "Romantic Comedy",
                    Rating      = "G",
                    Price       = 13.99M
                },

                    new movie
                {
                    Title       = "The Best Two Years",
                    ReleaseDate = DateTime.Parse("2004-2-20"),
                    Genre       = "Comedy",
                    Rating      = "G",
                    Price       = 15.99M
                },

                    new movie
                {
                    Title       = "The R.M.",
                    ReleaseDate = DateTime.Parse("2003-1-31"),
                    Genre       = "Comedy",
                    Rating      = "G",
                    Price       = 8.00M
                },

                    new movie
                {
                    Title       = "The Singles Ward",
                    ReleaseDate = DateTime.Parse("2002-1-30"),
                    Genre       = "Romantic Comedy",
                    Rating      = "G",
                    Price       = 12.99M
                }
                    );
                context.SaveChanges();
            }
        }