【问题标题】:update-database error - NuGet Package (EntityFramework.SqlMigrations)更新数据库错误 - NuGet 包 (EntityFramework.SqlMigrations)
【发布时间】:2023-03-18 13:52:01
【问题描述】:

我安装了 EntityFramework.SqlMigrations NuGet 包 我得到这个错误。 过去它对我有用,但不知何故,现在它不起作用了。

PM> 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:16
+ update-database <<<< 
    + CategoryInfo          : ObjectNotFound: (update-database:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

【问题讨论】:

    标签: entity-framework nuget-package entity-framework-migrations


    【解决方案1】:

    EF5 RTM、VS2012 RTM一起发生。

    我今天遇到了这个问题。我在 PM 控制台中执行了“Update-Package EntityFramework”。 NuGet 未报告任何更改,并且问题仍然存在。然后我重新启动了 VS2012 并重新尝试了 Update-Database,它按预期工作。目前还不清楚是什么导致了这个问题,也不清楚更新包是否有助于纠正它。

    首先尝试重新启动 Visual Studio,然后尝试 Update-Package EntityFramework,然后重新启动。

    【讨论】:

    • +1,重启就行了,所以看起来Update-Package EntityFramework 是不需要的。
    • 我认为人们正在经历两种不同的问题,它们的表现方式相同。有些人实际上需要强制更新包(例如,管理不善的解决方案从源代码控制中重新提取并带有挥之不去的 EF 工件),而其他人则发现了 PM 控制台无法正确初始化 EF 模块/cmdlet 的错误。
    【解决方案2】:

    我刚刚使用了这个命令:

    Update-Package EntityFramework -Reinstall
    

    【讨论】:

      【解决方案3】:

      就我而言,首先帮助安装了 EntityFramework 包:

      Install-Package EntityFramework
      

      然后再次安装 EntityFramework.Migrations:

      Install-Package EntityFramework.Migrations
      

      【讨论】:

      • 这并没有解决我的问题。此外,“EntityFramework.Migrations”包不再发布,因此该解决方案可能仅对“5.0-pre”包有效。
      【解决方案4】:

      不是最好的解决方案,但要让它再次工作,我必须重新安装 EntityFramework.Migrations 包。重新应用 Init.ps1 后,它会记住所有命令。

      【讨论】:

        【解决方案5】:

        在尝试了所有其他方法之后,我可以恢复我的 EntityFramework Migrations 命令的唯一方法是从“包管理器控制台”运行以下命令:

        Import-Module \*PathToSolution*\packages\EntityFramework.5.0.0-beta2\tools\EntityFramework.psd1
        

        运行以上后,Add-Migration、Update-Database等又可以使用了。

        【讨论】:

          【解决方案6】:

          重新启动 Visual Studio 为我解决了这个问题...

          【讨论】:

            【解决方案7】:

            对我来说,问题在于 Nuget 版本

            1. 卸载 Nuget 包管理器。
            2. 重新启动 Visual Studio。
            3. 已安装新版本的 Nuget 包管理器。
            4. 然后重新启动 Visual Studio

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2021-02-08
              • 1970-01-01
              • 2018-12-02
              • 1970-01-01
              • 1970-01-01
              • 2012-05-20
              相关资源
              最近更新 更多