2016-02-28 2 views
0

Je souhaite exécuter des commandes dnx à partir de la ligne de commande dans Visual Studio, mais cela ne fonctionne pas.ASP.NET MVC exécutant la commande Entity Framework sur la ligne de commande

Si je tape la commande:

dnx ef 

Je reçois l'erreur:

System.InvalidOperationException: No service for type 'Microsoft.Dnx.Runtime.IApplicationEnvironment' has been registered.
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Data.Entity.Commands.Program..ctor(IServiceProvider dnxServices)

Mon project.json contient ceci:

"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": { } 
}, 

Version 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 

version DNVM:

1.0.0-rc1-15540 

liste 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 

Répondre

0

I figured it out. Si vous obtenez des erreurs comme celle-ci, c'est probablement à cause de mauvaises dépendances. Ils doivent correspondre à votre environnement et aux autres dépendances. J'ai installé les lates de tous et ça a marché. Ceci est mes dépendances finales:

"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" 
},