39
PM> update-database
Build started...
Build succeeded.
The EF Core tools version '3.1.2' is older than that of the runtime '3.1.7'. Update the tools for the latest features and bug fixes.

I tried a local update. As different projects might use different versions on the same machine.

If I do this

$ dotnet tool update dotnet-ef

I get this error Cannot find a manifest file.

This is my version number:

$ dotnet ef --version
Entity Framework Core .NET Command-line Tools
3.1.5
Mali Tbt
  • 679
  • 1
  • 8
  • 12

3 Answers3

69

UPDATE This turned out to be an issue with a lot of facets. Main problem was Visual Studio: https://developercommunity.visualstudio.com/content/problem/438312/vs-2019-preview2-after-saving-edmx-code-is-not-gen.html


Please try

dotnet tool update --global dotnet-ef

and restart Visual Studio

Roar S.
  • 8,103
  • 1
  • 15
  • 37
  • After runnign this, I get this error - .dotnet/tools is int $PATH: The term 'Update-Database' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again – Mali Tbt Aug 18 '20 at 12:14
  • Please have a look at this question and see comment with 11 upvotes right below the question: https://stackoverflow.com/questions/9674983/the-term-update-database-is-not-recognized-as-the-name-of-a-cmdlet/21256165 He says: Simply exit and restart VS (or unload/reload the project) – Roar S. Aug 18 '20 at 12:16
  • I saw that and applied the solution they sugested. Including rebooting my machine but the same issue. I have entityframework core, design,sqlserver 3.1.7. My points are too low to comment on that question to discuss my issue. – Mali Tbt Aug 18 '20 at 12:29
  • Which version of Visual Studio are you using? Several solutions in this thread: https://stackoverflow.com/questions/40810258/the-term-update-database-is-not-recognized-as-the-name-of-a-cmdlet-function I guess a Nuget update to latest version of EntityFramework is the most likely one – Roar S. Aug 18 '20 at 12:31
  • Thanks. And what version of Nuget EntityFrameworkCore are you using? – Roar S. Aug 18 '20 at 13:01
  • As I said, it is 3.1.7 – Mali Tbt Aug 18 '20 at 13:04
  • visual studio: 16.6.3 – Mali Tbt Aug 18 '20 at 13:07
  • Ok, then both tools and EntityFrameworkCore should be the lastest and aligned. I will need some time to investigate further. While I am doing that, can you try to create a brand new EF Core project and see if that is working on your computer? – Roar S. Aug 18 '20 at 13:08
  • Please try this in order to make sure all setting are present: dotnet tool install --global dotnet-ef And make sure you have a dotnet-tools.json under .config folder. Should contain: "tools": { "dotnet-ef": { "version": "3.1.7", "commands": [ "dotnet-ef" ] } } – Roar S. Aug 18 '20 at 13:30
  • This is the result or running the command: Tool 'dotnet-ef' is already installed. closed/open VS And the term is still not recognized. What should be in $PATH? – Mali Tbt Aug 18 '20 at 13:37
  • That is just an info message, and is ok. What about dotnet-tools.json file I wrote about? – Roar S. Aug 18 '20 at 13:39
  • I don't have a .config folder (i checked for hidden folders: ls -la). where should it be? I have a project folder with Foo.sln & src/web/Foo.csproj & test/Foo.csproj – Mali Tbt Aug 18 '20 at 13:41
  • Run this in folder where your .sln file is: dotnet new tool-manifest then run: dotnet tool install --local dotnet-ef – Roar S. Aug 18 '20 at 13:46
  • Ran the commands successfully and got this: but still update-database is not recognized ````{ "version": 1, "isRoot": true, "tools": { "dotnet-ef": { "version": "3.1.7", "commands": [ "dotnet-ef" ] } } }```` – Mali Tbt Aug 18 '20 at 13:56
  • The visual studio update-database is not recognized but CLI commadn works - $ dotnet ef database update Build started... Build succeeded. Done. – Mali Tbt Aug 18 '20 at 13:59
  • Nice. Something wrong with VC settings then. You're not alone on this one: https://developercommunity.visualstudio.com/content/problem/438312/vs-2019-preview2-after-saving-edmx-code-is-not-gen.html – Roar S. Aug 18 '20 at 14:00
  • Updated my answer with link to VS-issue. If you feel that will be to any help to others, feel free to upvote my answer (not accept it). – Roar S. Aug 18 '20 at 14:16
4

There should be no harm using the newer tool with older versions of EF. You'll get bug fixes and features to the tool that should all be backwards compatible. Unless you are using different major versions (2.x vs 3.x) I think in this instance that --global is the right way to install/update the tool.

Otherwise you need to have a .config/dotnet-tools.json file in your project (or a directory above it somewhere). This is the manifest file that the error says is missing. You can create a new one with dotnet new tool-manifest but then you'll have to edit it yourself:

{
    "version": "1",
    "isRoot": true,
    "tools": {
        "dotnet-ef": {
            "version": "3.1.7",
            "commands": ["dotnet-ef"],
        }
    }
}

Once you've done that you need to run dotnet tool restore to restore and install the tool locally. More info on the manifest file can be found here. For dotnet-ef specifically, see here.

I'm not certain, but fairly positive that if you attempt to install the tool locally it should create the manifest and add the necessary info if it doesn't already exist. You might just need to try running dotnet tool install dotnet-ef within the project directory (and not update).

pinkfloydx33
  • 11,863
  • 3
  • 46
  • 63
3

It was still complaining and specifying the version worked for me:

dotnet tool update --global dotnet-ef --version x.x.x