Exemple #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new BookshelfContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <BookshelfContext> >()))
            {
                // Look for any books
                if (context.Book.Any())
                {
                    return;   // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Title       = "Pollyannna",
                    PublishDate = DateTime.Parse("1979-5-10"),
                    Genre       = "Fiction",
                    Author      = "Eleanor Potter",
                    Rating      = "R"
                },

                    new Book
                {
                    Title       = "The Complete Reference ",
                    PublishDate = DateTime.Parse("2010-7-07"),
                    Genre       = "Education",
                    Author      = "Herbert Shildt",
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
Exemple #2
0
 public IndexModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Exemple #3
0
 public EditModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Exemple #4
0
 public DeleteModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Exemple #5
0
 public DetailsModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Exemple #6
0
 public CreateModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }