Just now seeing this error when trying to run update-database
from PM console. I have the latest SDK installed.
I've tried repairing VS2017 and also uninstalling/reinstalling the latest .NET Core SDK.
What am I doing wrong here?
PM> update-database
The specified framework version '2.1' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.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.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
@bricelam can you comment? I am not familiar with how this update-database command interacts with core.
@aherrick What version of Microsoft.EntityFrameworkCore.Tools
is installed? What is the output with -Verbose
?
@bricelam thanks for the response. How can I figure that out?
C:\Users\aherrick>dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.4-rtm-31024
Running update-database -verbose
is probably enough. I think it shows the version
Build started...
Build succeeded.
C:\Users\aherrick\.nuget\packages\microsoft.entityframeworkcore.tools\2.1.4\tools\netcoreapp2.0\any\ef.dll
This project was originally a netstandard2.0
project, and we just moved it to netcoreapp2.1
would that have anything to do with it?
@bricelam is there anything else we need to look here? Is this something the CLI/SDK is doing wrong?
Hey all - I believe we figured this out. Our issue was we did have the correct project selected in PM, however the correct Project in the solution wasn't set as Startup. Once I set the actual Core Web project as Startup, it worked. Confusing to say the least!
Thanks for the help anyway!
I am facing the same error. My ef version is as below:
PS C:\Users\rsrivastavasource\accounting\api> dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.2-rtm-30932
adding below in csproj resolved it for me.
<RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
Similar issue here, I took a version specifically from the "The following versions are installed" and did what @rahul5163 said but put in the latest version I had there:
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
That helped.
aherrick's comment:
"the correct Project in the solution wasn't set as Startup. Once I set the actual Core Web project as Startup, it worked."
This was true for me, too. Once I set the project that held the DBContext class as the "startup project"; i.e., right-click the project and choose "Set as Startup Project", the initial migration worked just fine. But this project is also a class library, so some other adjustments will need to be made since I will eventually need a UI as the startup project vs. a class library.
I had to change the startup project to something else rather than Core project to make it work
Where exactly in the csproj file am I supposed to add <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
?
Does it go in the <PropertyGroup>
?
Had the same issue. This
Check application dependencies and target a framework version installed at
is a clue on what to do next. So, I added <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
and got output like this
Your startup project 'App.Database.Migrations.MySql' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
So the problem actually was a missing reference to Microsoft.EntityFrameworkCore.Design
package. Actually no need for the <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
.
Had the same issue here even after adding the <RuntimeFrameworkVersion>
. It seems that in some cases you don't only have to build the project to work but also run it once before trying to use ef commands.
I stumbled upon this problem when trying to generate new migration with Add-Migration
command. I just used dotnet ef migrations add Initial --project .\DatabaseProject\DatabaseProject.csproj --startup-project .\WebAppProject\WebAppProject.csproj
instead. Note that DatabaseProject must be referenced by WebAppProject in order to make it work.
// edit: my CLI tools version is Entity Framework Core 2.1.4-rtm-31024
Most helpful comment
Hey all - I believe we figured this out. Our issue was we did have the correct project selected in PM, however the correct Project in the solution wasn't set as Startup. Once I set the actual Core Web project as Startup, it worked. Confusing to say the least!
Thanks for the help anyway!