error NU1202: Package dotnet-ef 5.0.4 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any. Package dotnet-ef 5.0.4 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any code example

Example: error NU1202: Package dotnet-aspnet-codegenerator 5.0.1 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any. Package dotnet-aspnet-codegenerator 5.0.1 supports: net5.0 (.NETCoreApp,Version=v5.0)

//Update your .NET SDK to 5.0

//Change your target framework to in your project .csproj

  <PropertyGroup>
    <TargetFramework>netcoreapp5.0</TargetFramework>
  </PropertyGroup>