Error: It was not possible to find any compatible framework version (Add-Migration)

 Author: Shengtao Zhou       Created: 3/18/2019 4:02:37 AM       Modified: 3/18/2019 4:02:37 AM   More...
Just installed a power tool extension on Visual Studio and suddenly entity framework migration for my project stopped working. .Net core 2.1.1 runtime seems to be removed or upgraded somehow.

The problem:

When I run "Add-Migration Initial", I got the following error:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.1' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.2.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Solution:
Add the "GenerateRuntimeConfigurationFiles" to project file,
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
    <GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
  </PropertyGroup>

Check this link for more details:

Quote:
EF needs the *.runtimeConfig.json file to get framework roll forward behavior. Class libraries don't generate a *.runtimeConfig.json by default. The Design package basically adds this line to your project. If none of that happens, we fall back to running on the exact version the library is compiled against which fails if it's not installed.


More...          Back to List          

(Please enter you comments between 100 to 2000 characters. Thanks for your contribution.) 

         Created:       Modified: 

Editing a comment

       (Please enter you comments between 100 to 2000 characters. Please login before edit comment.) 

div class="col-md-2">