Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design
Solution 1:
I found the solution here.
In short, edit your csproj file, and add to your PropertyGroup
section following entry:
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
Solution 2:
None of the options worked for me. But the one I tried on this topic worked: EF Core 3 design time migrations broken by Microsoft.EntityFrameworkCore.Design DevelopmentDependency
I just commented out the following after importing the package to the Data project:
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<!--<PrivateAssets>all</PrivateAssets>-->
</PackageReference>
Thank you so much Microsoft by breaking the existing projects every time when you release a new .NetCore update!
Solution 3:
"Your 'project name' does not refer to your startup project Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Make sure your startup project is correct, install the package and try again."
If you get this error, try 'Build > Clean Solution' in your project and then try running your command again.
This worked in my project. Or you may want to look at the documentation.
I use .Net Core 3.1 version in my project.
Solution 4:
Do you have multiple projects? If yes then you have to make the host project as startup project from solution explorer and set the project as default (which project has DBContext) in PMC. Then run Add-Migration
command.