I'm following one of Mosh Hamedani Course on ASP.NET MVC in Udemy.
I came across one error while designing my Database using code-first (Entity Framework).
At first, I got the error of " No DbContext was found in assembly". After resolving this problem another one surged from nowhere.
The image below will show you the error found while adding a migration. I've already searched for the same error but in vain. I'm struggling for the past two hours but nothing is solved till now.
unable to create an object of type 'Vidly_Context'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
I ran into this issue when EF Core code first migrations in a .NET Core 3 solution that contains both an MVC project and a Blazor project.
If I have the solution's startup project set to the Blazor project I get the error when using
add-migration, but I don't if I have the startup project set to the MVC project.
From reading the documentation page linked to by the error message and comparing the code in the startup.cs files for both projects I'm not sure why that would be, but temporarily switching the startup project to the MVC project fixes it for me.