The term 'Update-Database' is not recognized as the name of a cmdlet

前端 未结 26 832
无人共我
无人共我 2020-12-07 19:35

I am using EF5 beta1 and while I was able to run the \"Update-Database\" before. Now that I shut down Visual Studio, I cannot get it to run. I get the following error:

相关标签:
26条回答
  • 2020-12-07 20:10

    In my case restarting Visual Studio (many, many times) did not work, then as I was looking elsewhere I found a message on the output terminal:

    The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.

    So I installed the required version of .NET Core and the command ran successfully.

    0 讨论(0)
  • 2020-12-07 20:12

    If the other answers don't work (VS 2017): clear the NuGet cache, restart VS, then restore the packages.

    0 讨论(0)
  • 2020-12-07 20:12

    I started having the same issue after I accidentally opened a Visual Studio solution with Visual Studio 2015 instead of 2017. The project worked just fine before that mishap. It was an older project with EF 5.0 and not EF Core.

    I tried everything suggested - restarted Visual Studio countless times, cleaned up NuGet cache, deleted everything in packages folder, reinstalled EF 5 for the project - no good, add-migration was not recognized. If I upgraded EF to 6, it started to recognize the commands, but I did not want to upgrade yet. So, as soon as I reverted back to EF 5, the problem returned.

    The only thing that finally saved me was to do the following:

    • close Visual Studio
    • delete everything from packages folder
    • delete .vs folder in the root of your solution. This folder is usually hidden, you have to turn on Show hidden files and folders setting or check Hidden items in folder View tab
    • start Visual Studio and open your solution. It will ask to restore NuGet packages, agree to it.

    Now EF commands finally started working again.

    0 讨论(0)
  • 2020-12-07 20:14

    For me it turns out EntityFramework core was not installed on my project (because i started with blank project). So installing EntityFramework package resolved the problem. Sometimes if EntityFramework installation failed then try to install individual packages one by one

    E.g.

    Microsoft.EntityFrameworkCore.Design
    Microsoft.EntityFrameworkCore.SqlServer
    Microsoft.EntityFrameworkCore.SqlServer.Design
    Microsoft.EntityFrameworkCore.Tools
    
    0 讨论(0)
  • 2020-12-07 20:16

    For me the problem was the Nuget version.

    I removed and re-installed Nuget then re-started Visual Studio and then all started working.

    0 讨论(0)
  • 2020-12-07 20:17

    This problem seems to happen when you open the project directly from File Explorer. Try starting VS first and then opening the project - worked for me. I'm guessing this is about access to paths.

    0 讨论(0)
提交回复
热议问题