19

I am deploying a new .NET Core application to my server. I'm trying to run the EntityFramework migration, as the project was created using the "code-first" method.

The command to be run is

dotnet ef database update

Migrations work locally using visual studio without issue, however, on the server, I receive the error;

Version for package Microsoft.EntityFrameworkCore.Tools.DotNet could not be resolved.

The version on my development machine of DotNet is 1.0.0

The version on my server of DotNet is 1.0.1

My project uses the .csproj file (not project.json, which is no longer used it seems).

I have added the reference to the csproj file, but regardless of the version I still get the above error.

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
  </ItemGroup>

Update

Basically I have tried installing the Microsoft.EntityFrameworkCore.Tools.DotNet from the command line using NUGET:

C:\Program Files (x86)\Jenkins\workspace\api.XXX.com\XXXProject>nuget i nstall Microsoft.EntityFrameworkCore.Tools.DotNet

Then I receive the following:

WARNING: Install failed. Rolling back... Executing nuget actions took 13.44 sec Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0' has a package type 'D otnetCliTool' that is not supported by project 'C:\Program Files (x86)\Jenkins\w orkspace\api.XXX.com\XXXProject'.`

Then if I run the dotnet ef command, I get this:

C:\Program Files (x86)\Jenkins\workspace\api.desully.com\deSullyAPI_Core>dotnet ef update database

Version for package Microsoft.EntityFrameworkCore.Tools.DotNet could not be re solved.

Update #2

I noticed that my dev machine has different SDK versions in it than the version on the server

Dev Box enter image description here

Production Box enter image description here

I'm assuming that the problem is that 1.0.1 doesn't have Microsoft.EntityFrameworkCore.Tools.DotNet in it? Isn't it strange that the older version does?

Update 3

So fyi - I went to the Microsoft Site to try to download the 1.0.0 version of the SDK (since it didn't seem to be installed on my server). Unfortunately, the MS site seems to force feed me the 1.0.1 version (which doesn't contain the EF stuff I need?).

I tried copying the 1.0.0 dir from my dev box to the production server, but that also didn't seem to work. What am I missing here?

5 Answers 5

41

There isn't a 1.0.1 version of Microsoft.EntityFrameworkCore.Tools.DotNet (at the time of writing). You need to set Version="1.0.0" in order to restore the package.

The available versions are listed on NuGet.

Update:

To use CLI tools, you first need to add <DotNetCliToolReference> items as you have already have.

Then you call dotnet restore in the directory of the project to download the packages to your local cache, then the tool becomes usable and dotnet ef can be used.

Sign up to request clarification or add additional context in comments.

6 Comments

I was just trying different numbers in there - but also same problem for 1.0.0.
Then please provide some more details: what tools / commands are executed? What is the exact error message? etc
updated answer. note that there is no need to call nuget install once your project has all the references it needs.
Getting somewhere now! This is the answer. Note - If anyone reverted to 1.0.0, you will get an error message asking for the project.json file when you run "dotnet ef update database" Make sure you install the 1.0.1 then run the dotnet restore, then run the database update command.
I first ran a dotnet command in the wrong folder, so when I ran it in the proper folder, I got this error. "dotnet restore" fixed it, thanks.
|
9

What helped in my case(.NET Core 2.0.3) was to issue:

dotnet add package Microsoft.EntityFrameworkCore.Design

And then

dotnet restore

This installed the Microsoft.EntityFrameworkCore.Tools.DotNet in a correct version

2 Comments

Was upgrading 2.0 > netcoreapp2.2. Had same problem, thanks.
Thank you, this solve my problem as well. I'm using netcore 3.1.2. So to be able to use the migration, we need to: - Install dotnet-ef tool - Install Microsoft.EntityFrameworkCore.Design & Microsoft.EntityFrameworkCore.Tools.DotNet - Add CLI tool reference to Microsoft.EntityFrameworkCore.Tools.DotNet
0

what worked in my case was using the cli including Microsoft.EntityFrameworkCore.Tools.DotNet Version="2.1.0-preview1-final, then after dotnet restore

1 Comment

i am using core 2.2.0
0

Change Microsoft.EntityFrameworkCore.Tools.Dotnet version to an available version, then run this on the CLI: dotnet restore. Then try again.

Comments

0

To enable migrations in dotnet core: 1 open command prompt and change directory to the .csproj location 2 run the command 'dotnet restore' #This will download and make th next command availe in the location 3 When completed, run the command 'dotnet ef'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.