Missing .Net Core 2.0 when reverse engineering a database in .Net 6
When reverse engineering a database (EF Core 6 / .Net 6) you may get an error saying that you should install .Net Core 2.0. Don’t install that since it is deprecated. You probably need to set the startup project and/or add some NuGet packages.
PS C:\Users\<username>\source\repos\Playground\Mixed.Frameworks\EfCore6> dotnet ef dbcontext scaffold -o Entities "Data Source=.;Initial Catalog=database_name;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer
Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
- The following frameworks were found:
3.1.23 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
5.0.15 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64
PS C:\Users\<username>\source\repos\Playground\Mixed.Frameworks\EfCore6>
Make sure that the following NuGet packages are installed before running the scaffold command:
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.SqlServer
Optionally you may want to install these packages if the database is using spatial data or hierarchyid:
Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
EntityFrameworkCore.SqlServer.HierarchyId
Make sure that the startup project has a refrence to the project where you are scaffolding to. It may help to use the --startup-project
option.