示例#1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new PublicLibraryContext(serviceProvider
                                                          .GetRequiredService <
                                                              DbContextOptions <PublicLibraryContext> >()))
            {
                if (context.Books.Any())
                {
                    return;
                }

                context.Books.AddRange(
                    new Models.Book
                {
                    Name       = "Sapiens",
                    AuthorName = "Yuval Noah Harari"
                },
                    new Models.Book
                {
                    Name       = "L'etranger",
                    AuthorName = "Albert Camus"
                });

                context.SaveChanges();
            }
        }
 public void Add(Form form)
 {
     dbContext.Add(form);
     dbContext.SaveChanges();
 }
示例#3
0
 public void Add(Book book)
 {
     dbContext.Add(book);
     dbContext.SaveChanges();
 }