'EF Migration: Could not load assembly. Ensure it is referenced by the startup project after switching from x64 to x86

After switching the all the projects to x86 architecture, I get the following error:

> dotnet ef migrations add Nullable-Fields --startup-project ..\LairageScanner.BlazorApp
Build started...
Build succeeded.
Could not load assembly 'LairageScanner.Context.SQL'. Ensure it is referenced by the startup project 'LairageScanner.BlazorApp'.

As seen above I have tried to run the command through CMD - but also done this for the package manager. I have seen some suggestion to fix this error: Stack Overflow & GitGub but neither of them had the solution to my issue.

Current Stack:

EF Core 3.1.3
Dotnet Core 3.1

Note: From the Git Solution it suggest converting to x64 and then just converting back later. And it does work. But I am looking for a more permanent solution.



Solution 1:[1]

I fixed it once with a simple action. You need to be sure that the Startup Project is the one with the startup.cs file. Also, be sure that all Project references are complete.

Well, it worked for me.

Solution 2:[2]

enter image description here

Select the layer where the dbcontext class exists

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander Protto
Solution 2 Dharman