Ho creato una libreria di classi ASP.NET 5 con le seguenti dipendenze
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final"
Ho creato il mio modello e le classi DatabaseContext. Ora voglio aggiungere una migrazione in modo da poter creare il database. A chiamata
dnx ef Add-Migration InitialMigration
dalla riga di comando che mi sta dando il seguente messaggio di errore
System.InvalidOperationException: l'attuale framework di destinazione runtime non è compatibile con 'Yugasat.Test'. Current target framework di runtime: 'DNX, Version = v4.5.1 (dnx451)' Versione:
1.0.0-rc1-16231 Tipo: Clr Architecture: x86 Nome SO: Windows OS Versione: 10.0 Id di runtime: win10-x86Assicurarsi che il runtime corrisponda a un framework specificato in project.json in Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint (String applicationName) in Microsoft.Dnx.ApplicationHost.Program.ExecuteMain (host DefaultHost, string applicationName, String [] args) presso Microsoft.Dnx.ApplicationHost.Program.Main (String [] args) --- Traccia di fine dello stack dalla posizione precedente in cui è stata generata un'eccezione --- su System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in Microsoft.Dnx.Runtime .Common.EntryPointExecutor.Execute (Assembly assembly, String [] args, IServiceProvider serviceProvider) in Microsoft.Dnx.Host.Bootstrapper.RunAsync (List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework) in Microsoft.Dnx.Host. RuntimeBootstrapper.ExecuteAsync (String [] args, BootstrapperContext bootstrapperContext) in Microsoft.Dnx.Host.RuntimeBootstrapper.Execute (String [] args, BootstrapperContext bootstrapperContext)
Per quanto posso vedere dal messaggio di errore la mia versione dnx è 4.5.1 e il framework nel mio file projects.json è impostato su 4.5.1
{
"version": "1.0.0-*",
"description": "Yugasat.Test Class Library",
"authors": [ "AndreL" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
}
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final"
},
"commands": {
"ef": "EntityFramework.Commands"
}
}
"frameworks": {
"net451": {}
}
Devi usare dnx451
qui, non net451
. Quindi, l'attuale framework di destinazione runtime (che è DNX,Version=v4.5.1 (dnx451)
) lo raccoglierà correttamente.
Si noti inoltre che il comando corretto è dnx ef migrations add InitialMigration
; IA € ™ non sono sicuro se il Add-Migration
funziona.