コード例 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MVCMovieContext> >()))
            {
                if (context.Movie.Any())
                {
                    return;
                }

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

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

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

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Rating      = "NR",
                    Price       = 3.99M,
                    PosterURL   = ""
                }

                    );
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MVCMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "Emma Smith: My Story",
                    Rating      = "G",
                    ReleaseDate = DateTime.Parse("2008-4-11"),
                    Genre       = "Historical Drama",
                    Price       = 10.99M
                },

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

                    new Movie
                {
                    Title       = "The Singles 2nd Ward",
                    Rating      = "PG",
                    ReleaseDate = DateTime.Parse("2007-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M
                },

                    new Movie
                {
                    Title       = "Mobsters and Mormons",
                    Rating      = "PG",
                    ReleaseDate = DateTime.Parse("2005-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
コード例 #3
0
ファイル: SeedData.cs プロジェクト: radtek/Work-Placement
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MVCMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "Avengers: Infinity War",
                    ReleaseDate = DateTime.Parse("2018-4-27"),
                    Genre       = "Action",
                    Price       = 7.99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "Avatar",
                    ReleaseDate = DateTime.Parse("2009-12-21"),
                    Genre       = "Science Fiction",
                    Price       = 8.99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "Superbad",
                    ReleaseDate = DateTime.Parse("2007-8-16"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "X-Men",
                    ReleaseDate = DateTime.Parse("2000-6-9"),
                    Genre       = "Action",
                    Price       = 3.99M,
                    Rating      = "PG-13"
                }
                    );
                context.SaveChanges();
            }
        }
コード例 #4
0
ファイル: SeedData.cs プロジェクト: jsmith302/dotnetprojects
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new MVCMovieContext(
                serviceProvider.GetRequiredService <DbContextOptions
                                                    <MVCMovieContext> >()))
     {
         if (context.Movie.Any())
         {
             return;
         }
         foreach (var movie in context.Movie)
         {
             context.Movie.Remove(movie);
         }
         context.Movie.AddRange(
             new Movie
         {
             Title       = "When Harry Met Sally",
             ReleaseDate = DateTime.Parse("1989-01-11"),
             Genre       = "Romantic Comedy",
             Price       = 7.99M,
             Rating      = "R"
         },
             new Movie
         {
             Title       = "Ghostbusters",
             ReleaseDate = DateTime.Parse("1984-03-13"),
             Genre       = "Comedy",
             Price       = 7.99M,
             Rating      = "PG-13"
         },
             new Movie
         {
             Title       = "HItch",
             ReleaseDate = DateTime.Parse("2000-02-14"),
             Genre       = "Romantic Comedy",
             Price       = 7.99M,
             Rating      = "PG-13"
         },
             new Movie
         {
             Title       = "Halloween",
             ReleaseDate = DateTime.Parse("1990-10-31"),
             Genre       = "Horror",
             Price       = 7.99M,
             Rating      = "R"
         });
         context.SaveChanges();
     }
 }
コード例 #5
0
ファイル: SeedData.cs プロジェクト: LookForward/NetCore
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MVCMovieContext> >()))
            {
                // 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",
                    Price       = 7.99M
                },

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

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

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }