data/authors/Paul Logan.json

Upgrading from EF Core 6 to 8

Nullable Reference Types


Swathes of “Dereference of a possibly null reference (CS8602)” warning messages in a few of my dotnet core apps that I was re-visiting, prompted me to look into this unfamiliar warning and how to resolve it.

A great series about it here

Then I saw this here

Although this generally causes a compiler warning, EF Core 7.0 and above suppress this warning, since EF automatically initializes these properties via reflection.

As my apps were in .NET Core 6, an upgrade to the current EF Core 8 seemed warranted - gaining from the latest .NET Core improvements and resolve the issues in a way that doesn’t mess with the concept of null (null!).

Upgrade Commands

Firstly, to automate the upgrade procedure, I installed the .Net Upgrade Assistant CLI tool. If a previous version of the upgrade assisstant is already installed in your project, run the uninstall first, then install to get the latest.

dotnet tool uninstall upgrade-assistant
dotnet tool install upgrade-assistant
dotnet upgrade-assistant upgrade
dotnet tool update dotnet-ef

A dotnet run of the app on my dev machine resulted in:

DotNet Upgrade Error
The certificate chain was issued by an authority that is not trusted

This is a known (not by me), security-related, breaking change introduced in EF Core 7. There is a straightforward fix for getting your app up and running again:

Explicitly add Encrypt=False to the connection string

Brakpoints not enabled

Then, when debugging by hitting F5, my debug breakpoints were greyed out and displayed the following message:

The source code is different from the original version. To allow this breakpoint to be hit….

The upgrade assisstant did not change the reference to the new target framework in launch.json. Now that I have just pasted the code here, I spot the comment to “make sure to update the program path”. Now, one of my main goals when developing software is to minimise the amount of “remember you have to do this” responsibilities I place on my application users. This should be automated!

    "version": "0.2.0",
    "configurations": [
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/net6.0/ZebraPrintManager.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"