Tuesday, May 17, 2022

EF irrelevant error when creating migration It was not possible to find any compatible framework version

 When adding a migration you may get following error: 

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.22 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
5.0.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.



Please note that this error is totally wrong and irrelevant. This is not an error of framework version, but error of path declarations. 


The best way to resolve this error is  

1. Make the Web API project a startup project. 

2. Select the project where DBContext resides as default in PM console. 

3. In PM Console, navigate to the path of Web API project. 

4. Now give the following command : 

dotnet ef migrations add NameOfYourMigration --project  ..\PathOfDbContextProject\DbContextProject.csproj


Remember the command "dotnet ef migrations add"  some people forget to write "migrations" , they write "migration" instead. 


No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...