我想在Visual Studio中从命令行运行dnx命令,但它不起作用。
如果我输入命令:
dnx ef
我收到错误:
System.InvalidOperationException:没有类型的服务' Microsoft.Dnx.Runtime.IApplicationEnvironment'已经注册 在Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider提供程序,类型serviceType)
在Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService [T](IServiceProvider提供者)
在Microsoft.Data.Entity.Commands.Program..ctor(IServiceProvider dnxServices)
我的project.json
包含此内容:
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-beta8",
"Microsoft.Framework.SecretManager": "1.0.0-beta8"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
DNX版本:
Microsoft .NET Execution environment
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
DNVM版本:
1.0.0-rc1-15540
DNVM列表:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 clr x64 win
* 1.0.0-rc1-update1 clr x86 win default
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
答案 0 :(得分:0)
我明白了。 如果你得到这样的错误,可能是因为错误依赖。 他们需要匹配您的环境和其他依赖项。 我安装了所有的lates并且它工作了。 这是我的最终依赖:
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"Microsoft.Framework.SecretManager": "1.0.0-beta8"
},