【问题标题】:Why does calling "get-help entityframework" in the Package Manager Console cause this error?为什么在包管理器控制台中调用“get-help entityframework”会导致此错误?
【发布时间】:2019-04-25 09:54:40
【问题描述】:
PM> get-help entityframework

get-help : 对象引用未设置为对象的实例。
在 line:1 char:1
+ 获取帮助实体框架
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Help], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetHelpCommand

我猜这可能是与 PowerShell 相关的问题,所以我在这里列出了它的版本号

PM> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      0      10586  494     

我正在使用

Microsoft Visual Studio Community 2017
Version 15.8.7

【问题讨论】:

  • 您的意思可能是Get-Help about_EntityFrameworkCore Get-Help 很细致,但您可以插入* 通配符Get-Help about_Entity*
  • "get-help nuget" 或其他类似的命令给我一个类似的错误
  • 我认为它应该可以从任何提供商/位置工作,但是当您更改位置时会发生什么:Set-Location C:?
  • @iRon 抱歉,但 Set-Location 与此问题无关

标签: visual-studio powershell package-manager-console nuget-cli


【解决方案1】:

一旦我安装了 NuGet 包 Microsoft.EntityFrameworkCore.Tools,错误就消失了,我看到了我的列表...

PM> 获取帮助实体框架

                 _/\__
           ---==/    \\
     ___  ___   |.    \|\
    | __|| __|  |  )   \\\
    | _| | _|   \_/ |  //|\\
    |___||_|       /   \\\/\\

主题 about_EntityFrameworkCore

简短说明 提供有关 Entity Framework Core 包管理器控制台工具的信息。

详细说明 本主题介绍 Entity Framework Core 包管理器控制台工具。见https://docs.efproject.net 有关 Entity Framework Core 的信息。

The following Entity Framework Core commands are available.

    Cmdlet                      Description
    --------------------------  ---------------------------------------------------
    Add-Migration               Adds a new migration.

    Drop-Database               Drops the database.

    Get-DbContext               Gets information about a DbContext type.

    Remove-Migration            Removes the last migration.

    Scaffold-DbContext          Scaffolds a DbContext and entity types for a database.

    Script-DbContext            Generates a SQL script from the current DbContext. 

    Script-Migration            Generates a SQL script from migrations.

    Update-Database             Updates the database to a specified migration.

另请参阅 添加迁移 删除数据库 获取 DbContext 移除迁移 脚手架-DbContext 脚本-DbContext 脚本迁移 更新数据库

【讨论】:

    【解决方案2】:

    您最近是否升级了任何相关组件?我问是因为另一个用户在 MVC 升级后看到了与 NuGet 类似的行为:https://github.com/NuGet/Home/issues/2192

    检查您的 NuGet 和实体框架包是否是最新的。

    还有其他字符串 get-help 会返回类似的错误吗?如果没有,也许甚至卸载并重新安装实体框架?

    【讨论】:

    • 我检查了 Nuget 和 Entity 框架是最新的
    【解决方案3】:

    安装了 NuGet 包 -> Microsoft.EntityFrameworkCore.Tools

    关于_entityframeworkcore的帮助

                     _/\__
               ---==/    \\
         ___  ___   |.    \|\
        | __|| __|  |  )   \\\
        | _| | _|   \_/ |  //|\\
        |___||_|       /   \\\/\\
    

    主题 about_EntityFrameworkCore

    简短说明 提供有关 Entity Framework Core 包管理器控制台工具的信息。

    详细说明 本主题介绍 Entity Framework Core 包管理器控制台工具。见https://docs.efproject.net 有关 Entity Framework Core 的信息。

    The following Entity Framework Core commands are available.
    
        Cmdlet                      Description
        --------------------------  ---------------------------------------------------
        Add-Migration               Adds a new migration.
    
        Drop-Database               Drops the database.
    
        Get-DbContext               Gets information about a DbContext type.
    
        Remove-Migration            Removes the last migration.
    
        Scaffold-DbContext          Scaffolds a DbContext and entity types for a database.
    
        Script-DbContext            Generates a SQL script from the current DbContext. 
    
        Script-Migration            Generates a SQL script from migrations.
    
        Update-Database             Updates the database to a specified migration.
    

    另请参阅 添加迁移 删除数据库 获取 DbContext 移除迁移 脚手架-DbContext 脚本-DbContext 脚本迁移 更新数据库

    【讨论】:

      【解决方案4】:

      首先使用以下命令安装实体框架工具。

      PM > Install-Package Microsoft.EntityFrameworkCore.Tools

      【讨论】:

        【解决方案5】:

        我遇到了同样的问题。 检查您是否安装了 Microsoft.EntityFrameworkCore.Tools 包。 我猜你没有,因为当我没有这样的包时,我也遇到了同样的问题。

        安装 Microsoft.EntityFrameworkCore.Tools 后 PM> 获取帮助实体框架 再检查一遍,你会得到你想要的结果)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-09-10
          • 1970-01-01
          • 2013-10-19
          • 2020-09-02
          • 1970-01-01
          相关资源
          最近更新 更多