Querying EF Core models
Now that we have a model that maps to the Northwind database and two of its tables, we can write some simple LINQ queries to fetch data. You will learn much more about writing LINQ queries in Chapter 11, Querying and Manipulating Data Using LINQ.
For now, just write the code and view the results:
- Add a new class file named
Program.Helpers.cs
. - In
Program.Helpers.cs
, add a partialProgram
class with aSectionTitle
method, as shown in the following code:partial class Program { static void SectionTitle(string title) { ConsoleColor previousColor = ForegroundColor; ForegroundColor = ConsoleColor.Yellow; WriteLine("*"); WriteLine($"* {title}"); WriteLine("*"); ForegroundColor = previousColor; } static void Fail(string message) { ConsoleColor previousColor = ForegroundColor; ForegroundColor = ConsoleColor.Red; WriteLine($"Fail > {message}"); ForegroundColor...