Sto cercando di creare la migrazione ma non riesce con Value cannot be null. Parameter name: contentRootPath.
. Stesso errore da entrambe le dotnet ef migrations add
e dotnet ef migrations script
.
Ecco l'output dettagliato completo:
PS C:\mypath> dotnet ef migrations add foo --project .\MyDataProject\ --startup-project .\MyAppProject\ -v
Using project '.\MyDataProject\MyDataProject.csproj'.
Using startup project '.\MyAppProject\MyAppProject.csproj'.
Writing '.\MyDataProject\obj\MyDataProject.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\myname\AppData\Local\Temp\tmpE078.tmp /verbosity:quiet /nologo .\MyDataProject\MyDataProject.csproj
Writing '.\MyAppProject\obj\MyAppProject.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\myname\AppData\Local\Temp\tmpE403.tmp /verbosity:quiet /nologo .\MyAppProject\MyAppProject.csproj
dotnet build .\MyAppProject\MyAppProject.csproj /verbosity:quiet /nologo
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyOtherProject\MyOtherProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyDataProject\MyDataProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyDataProject\MyDataProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyOtherProject\MyOtherProject.csproj]
Build succeeded.
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyOtherProject\MyOtherProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyDataProject\MyDataProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyDataProject\MyDataProject.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ObsoleteReferences.targets(33,5): warning NETSDK1059: The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box). [C:\mypath\MyOtherProject\MyOtherProject.csproj]
4 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.31
C:\Program Files\dotnet\sdk\2.1.502\DotnetTools\dotnet-ef\2.1.4\tools\netcoreapp2.1\any\tools\net461\win-x86\ef.exe migrations add foo --assembly C:\mypath\MyAppProject\bin\Debug\net461\MyDataProject.dll --startup-assembly C:\mypath\MyAppProject\bin\Debug\net461\MyAppProject.exe --project-dir C:\mypath\MyDataProject\ --language C# --working-dir C:\mypath --verbose --root-namespace MyDataProject
Using assembly 'MyDataProject'.
Using startup assembly 'MyAppProject'.
Using application base 'C:\mypath\MyAppProject\bin\Debug\net461'.
Using working directory 'C:\mypath\MyAppProject'.
Using root namespace 'MyDataProject'.
Using project directory 'C:\mypath\MyDataProject\'.
Using configuration file 'C:\mypath\MyAppProject\bin\Debug\net461\MyAppProject.exe.config'.
System.ArgumentNullException: Value cannot be null.
Parameter name: contentRootPath
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String environment, String projectDir, String contentRootPath, String rootNamespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<>c__DisplayClass4_0.<.ctor>b__4()
at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: contentRootPath
Quando ho eseguito Add-Migration
nella console di gestione dei pacchetti di Visual Studio, la Add-Migration
eseguita correttamente.
Cosa devo fare per avere successo nella riga di comando con dotnet.exe? Mi sto perdendo qualcosa?
Alla fine, ho trovato un altro progetto che ha funzionato per me e la differenza tra esso e questa era la versione di EntityFramework.
L'aggiornamento di EntityFramework Core dalla 1.1 alla 2.0 ha risolto il mio problema.