public void CreateSomeBooks(BooksDbContext dbContext) { var stephenKing = new Author { Name = "Stephen King" }; stephenKing.WriteBook("It"); stephenKing.WriteBook("Carrie"); stephenKing.WriteBook("Christine"); dbContext.Authors.Add(stephenKing); dbContext.SaveChanges(); }
static void Main(string[] args) { using (var dbContext = new BooksDbContext()) { dbContext.Database.EnsureCreated(); var booksWithReallyShortTitles = dbContext.Books .Where(book => book.Title.Length > 10) .OrderBy(book => book.Title.Length); foreach (var book in booksWithReallyShortTitles) { Console.WriteLine(book.Title); } // foreach(var book in dbContext.Books) { // Console.WriteLine(book); // } } }