예제 #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();
            }
        }
예제 #2
0
 public void Add(Form form)
 {
     dbContext.Add(form);
     dbContext.SaveChanges();
 }
예제 #3
0
 public void Add(Book book)
 {
     dbContext.Add(book);
     dbContext.SaveChanges();
 }