我正在尝试按照本教程: 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",
任何想法?
彼得
答案 0 :(得分:3)
我有一个类似的问题,我无法从包管理器控制台运行add-migration;它产生了同样的错误。在我的情况下,.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"
},
答案 1 :(得分:0)
您需要安装最新版本1.1.0
。问题出在1.0.0-preview2-final
上。
您可以在GIT上看到详细信息:EFCore 1.1.0 Preview Final 1 Scaffold-DbContext Error