【问题标题】:.NET Core EF Scaffolding throws unable to find provider assembly 'Source=localhost'.NET Core EF 脚手架引发无法找到提供程序程序集“Source=localhost”
【发布时间】:2021-09-14 12:10:19
【问题描述】:

我正在使用核心 3,并且我在我的项目中包含以下包

"Microsoft.EntityFrameworkCore.Design": "5.0.7",
"Microsoft.EntityFrameworkCore.SqlServer": "5.0.7",
"Microsoft.EntityFrameworkCore.Tools": ""5.0.7""

这是我的连接字符串,我之前已经测试过连接并且它成功了

  "ConnectionStrings": { "bikeStore": "Data Source=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********" }

现在我想运行下面的 Scaffold 命令

Scaffold-DbContext Data Source=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data

我得到以下错误

Build started...
Build succeeded.
Unable to find provider assembly 'Source=localhost'. Ensure the name is correct and it's referenced by the project.

这是服务器资源管理器以及我如何连接到我的数据库

我的方法有什么问题?

【问题讨论】:

  • 您可以尝试将连接字符串中的Data Source 替换为Server 吗?
  • 我现在试过了,它显示了这个,不确定它是什么意思'cmdlet Scaffold-DbContext at command pipeline position 1 Supply values for the following parameters: Provider:' 我应该为提供者写什么?跨度>

标签: entity-framework asp.net-web-api .net-core scaffolding


【解决方案1】:

您可以将Data Source 替换为Server 并提供提供者标志:

Scaffold-DbContext -Connection "Server=localhost;Initial Catalog=BikeStore;User ID=sa;Password=***********;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data

【讨论】:

    猜你喜欢
    • 2013-03-07
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 2021-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-30
    相关资源
    最近更新 更多