3

I've seen similar questions to this and I've tried every posted solution to all of them. I've been trying to fix this seemingly simple problem for the past two days and have gotten nowhere. When I try to run Add-Migration or Update-Database from the Package Manager Console, I get the following error:

Update-Database : 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. At line:1 char:1 + Update-Database + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Update-Database:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

or

Add-Migration : The term 'Add-Migration' 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. At line:1 char:1 + Add-Migration TestMigration + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Here is my project.json:

{
  "dependencies": {
    "Braintree": "3.5.0",
    "CoreCompat.System.Drawing": "1.0.0-beta006",
    "Google.Apis.Auth": "1.20.0",
    "Google.Apis.Oauth2.v2": "1.20.0.672",
    "MailKit": "1.10.1",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "RazorLight": "1.0.0-rc1",
    "RazorLight.MVC": "1.0.3",
    "SendGrid.NetCore": "1.0.0-rtm-00002",
    "Tinify": "1.5.0"
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },
  "scripts": {
  "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I've tried running dotnet restore, restarting Visual Studio, running Visual Studio as administrator, restarting my computer, deleting the dependencies to EntityFramework and re-adding them.

I need to be able to run Add-Migration to update my SQL database, any help would be appreciated.

EDIT:

I ended up just creating a new project, installing all of the dependencies again and copying my code over. That did the trick, but an actual solution could still help, and help others with a similar problem.

mcjcloud
  • 351
  • 2
  • 11
  • Looks like you reference EF Core, but are trying to use EF 6 commands. For core, see [here](https://learn.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations). – Steve Greene Apr 16 '17 at 22:00
  • @SteveGreene The link you posted is directed at .NET Core 1.1 whereas I'm currently using 1.0. Also, these commands worked for me previously and all of a sudden do not. – mcjcloud Apr 16 '17 at 22:38
  • Yes, didn't catch that. So you've tried all [these](http://stackoverflow.com/questions/38173404/the-term-add-migration-is-not-recognized)? – Steve Greene Apr 16 '17 at 23:26
  • Yes unfortunately – mcjcloud Apr 16 '17 at 23:27

1 Answers1

1

Just install Microsoft.EntityFrameworkCore.Tools package from nuget:

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.1.1

You can also use this link to install the latest version: Nuget package link

Copied from Nasir Jafarzadeh

Tigerware
  • 3,196
  • 2
  • 23
  • 39
  • Thanks. I had restarted and run Install-Package Microsoft.EntityFrameworkCore many times until I saw this post. Install-Package Microsoft.EntityFrameworkCore.Tools sorted it out for me. – ShaunP Sep 16 '20 at 12:14