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

                context.Book.AddRange(
                    new Book
                {
                    Title       = "Frankenstein",
                    Author      = "Mary Shelley",
                    ReleaseDate = DateTime.Parse("1818-1-1"),
                    Genre       = "Horror",
                    Price       = 7.99M
                },

                    new Book
                {
                    Title       = "The Great Gatsby",
                    Author      = "F. Scott Fitzgerald",
                    ReleaseDate = DateTime.Parse("1925-4-10"),
                    Genre       = "Tragedy",
                    Price       = 8.99M
                },

                    new Book
                {
                    Title       = "Moby Dick",
                    Author      = "Herman Melville",
                    ReleaseDate = DateTime.Parse("1851-10-18"),
                    Genre       = "Adventure",
                    Price       = 9.99M
                },

                    new Book
                {
                    Title       = "The Time Machine",
                    Author      = "H.G. Wells",
                    ReleaseDate = DateTime.Parse("1895-1-1"),
                    Genre       = "Science Fiction",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcBookContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcBookContext> >()))
            {
                // Look for any movies.
                if (context.Book.Any())
                {
                    return;   // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Title       = " Anna Karenina",
                    Author      = " Leo Tolstoy",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Classic",
                    Price       = 7.99M
                },

                    new Book
                {
                    Title       = " War and Peace",
                    Author      = "Leo Tolstoy",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Classic",
                    Price       = 8.99M
                },

                    new Book
                {
                    Title       = "Madame Bovary",
                    Author      = "Gustave Flaubert",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Classic",
                    Price       = 9.99M
                },

                    new Book
                {
                    Title       = "The Great Gatsby",
                    Author      = "F. Scott Fitzgerald",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Classic",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcBookContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcBookContext> >()))
            {
                // Look for any books.
                if (context.Book.Any())
                {
                    return;   // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Title       = "The Shining",
                    Author      = "Stephen King",
                    ReleaseDate = DateTime.Parse("1977-28-1"),
                    Price       = 7.99M
                },

                    new Book
                {
                    Title       = "Dr. Sleep",
                    Author      = "Stephen King",
                    ReleaseDate = DateTime.Parse("2012-14-8"),
                    Price       = 8.5M
                },

                    new Book
                {
                    Title       = "Eragon",
                    Author      = "Christopher Paolini",
                    ReleaseDate = DateTime.Parse("2010-23-2"),
                    Price       = 17M
                },

                    new Book
                {
                    Title       = "Lord Of The Rings",
                    Author      = "J. R. R. Tolkien",
                    ReleaseDate = DateTime.Parse("1935-12-5"),
                    Price       = 14M
                }
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcBookContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcBookContext> >()))
            {
                // Look for any books.
                if (context.Book.Any())
                {
                    return; // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Title           = "The Hunger Games",
                    Author          = "Suzanne Collins",
                    Genre           = "Teen",
                    Pages           = 448,
                    ReleaseDate     = DateTime.Parse("2008-09-14"),
                    FinishedReading = true
                },

                    new Book
                {
                    Title           = "A Game of Thrones",
                    Author          = "George R.R. Martin",
                    Genre           = "Fantasy",
                    Pages           = 912,
                    ReleaseDate     = DateTime.Parse("1996-08-01"),
                    FinishedReading = false
                },

                    new Book
                {
                    Title       = "The Lord of the Rings",
                    Author      = "J.R.R. Tolkien",
                    Genre       = "Fantasy",
                    Pages       = 1552,
                    ReleaseDate = DateTime.Parse("1954-07-29")
                }
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcBookContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcBookContext> >()))
            {
                //Look for any books
                if (context.Book.Any())
                {
                    return; //DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Title       = "The Chronicles of Narnia:The Lion, the Witch and the Wardrobe",
                    Author      = "C. S. Lewis",
                    Genre       = "Fantasy",
                    ReleaseDate = DateTime.Parse("1951-10-15"),
                    Review      = 8
                },

                    new Book
                {
                    Title       = "Harry Potter and the Chamber of Secrets",
                    Author      = "J.K.Rowling",
                    Genre       = "Fantasy",
                    ReleaseDate = DateTime.Parse("1998-07-02"),
                    Review      = 9
                },

                    new Book
                {
                    Title       = "City of Bones",
                    Author      = "Cassahndra Clare",
                    Genre       = "Adventure",
                    ReleaseDate = DateTime.Parse("2007-03-27"),
                    Review      = 6
                }
                    );
                context.SaveChanges();
            }
        }