using Library; using Library.DbContextLib; using Library.Entities; using Microsoft.Extensions.Options; // See https://aka.ms/new-console-template for more information Console.WriteLine("Hello, World!"); using (var context = new LibraryContext()) { BookEntity chewie = new BookEntity("B3", "test", "test2"); BookEntity yoda = new BookEntity ("B4", "test", "test2"); BookEntity ewok = new BookEntity ("C5", "test", "test3"); context.BooksSet.Add(chewie); context.BooksSet.Add(yoda); context.BooksSet.Add(ewok); context.SaveChanges(); } using (var context = new LibraryContext()) { foreach (var n in context.BooksSet) { Console.WriteLine($"{n.ID} - {n.Title}"); } context.SaveChanges(); } using (var context = new LibraryContext()) { var eBooks = context.BooksSet.Where(b => b.Title.StartsWith("B")).First(); Console.WriteLine($"{eBooks.Title} (born in {eBooks.Author})"); eBooks.Title = "Wicket"; context.SaveChanges(); }