【问题标题】:Creating classes from Postgres database for Entity Framework Core从 Postgres 数据库为 Entity Framework Core 创建类
【发布时间】:2021-04-04 20:57:39
【问题描述】:

寻找一种从现有 Postgres 13 数据库自动创建实体类的方法。 在

根据

http://www.npgsql.org/efcore/index.html

在 Visual Studio 2019 命令提示符中

dotnet ef dbcontext scaffold "Host=my_host;Database=my_db;Username=my_user;Password=my_pw" Npgsql.EntityFrameworkCore.PostgreSQL

命令应该这样做,但它会抛出错误

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-ef does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

NpgSql.EntityFrameworkCore.PostgreSQL v5.0.1 包是从 Nuget 安装的。

【问题讨论】:

    标签: asp.net-core .net-core entity-framework-core visual-studio-2019 npgsql


    【解决方案1】:

    您应该安装 Dotnet EF 工具。

    在你的包管理器控制台中试试这个

    dotnet tool install --global dotnet-ef
    

    之后建议同时安装设计工具,以便您可以在特定项目上使用工具

    dotnet add package Microsoft.EntityFrameworkCore.Design
    

    【讨论】:

      猜你喜欢
      • 2019-02-12
      • 2017-06-01
      • 2021-06-30
      • 2017-07-10
      • 1970-01-01
      • 2019-06-08
      • 1970-01-01
      • 2019-07-23
      • 1970-01-01
      相关资源
      最近更新 更多