錯誤:無法執行此命令,因為未安裝Microsoft.EntityFrameworkCore.Design

c# entity-framework entity-framework-core

我正在嘗試按照本教程: https//docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html

當我嘗試運行時:
Scaffold-DbContext "Server=myserver1;Database=mydb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

我收到此錯誤:
Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.

這是我的project.json的一部分

"tools": {
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",

有任何想法嗎?
彼得

熱門答案

我有一個類似的問題,我無法從包管理器控制台運行add-migration;它產生了同樣的錯誤。在我的情況下缺少"type": "platform" .netcore.app的"type": "platform"是問題。我不得不改變

"Microsoft.NETCore.App": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"

"Microsoft.NETCore.App":
{
  "version": "1.1.0",
  "type": "platform"
},
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"

然後添加到工具部分

"tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
  },


Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因