Adding logging
It's sometimes important, namely when things go wrong, to get a glimpse of what's going on inside. For that, we can leverage the logging capabilities of Entity Framework Core: we are presented with a detailed register of what is happening, such as the SQL that is being sent to the database.
Getting ready
We will be using the NuGet Package Manager to install the Entity Framework Core 1 package, Microsoft.EntityFrameworkCore
. We will also be using a SQL Server database to store the data, so we will also need Microsoft.EntityFrameworkCore.SqlServer
.
We also need the Microsoft.Extensions.Logging
and Microsoft.Extensions.Logging.Console
packages to add logging capabilities.
Open Using EF Core Solution from the included source code examples. ...
Get Entity Framework Core Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.