我正在使用EF Core,我正在尝试从数据库生成模型。我创建了一个单独的ASP.NET核心Web应用程序,因为从类库中生成它并不适合我。
我已经成功地从数据库生成了几次实体类,但突然间它停止了工作。这真的很奇怪,因为我这不是第一次,我不会改变什么,导致它停止工作的原因是什么?
这是project.json:
{
"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
}
}
这是命令:
Scaffold-DbContext "Server= myserver;Database=db;User Id=sa;Password=pass;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir EntityModels
错误:
Scaffold-DbContext : The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Scaffold-DbContext "Server=myserver;Database=db...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Scaffold-DbContext:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我重新启动了visual studio,问题仍然存在。
答案 0 :(得分:1)
dependencies
中的版本与tools
不同:
来自dependencies
:
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
来自tools
:
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",