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(); }
public void Add(Book book) { dbContext.Add(book); dbContext.SaveChanges(); }