dotnet ef migrations: Value cannot be null. Parameter name: contentRootPath

c# dotnet-cli entity-framework-core

Question

I'm trying to create migration but it fails with Value cannot be null. Parameter name: contentRootPath.. Same error from both dotnet ef migrations add and dotnet ef migrations script.

Here is the full verbose output:

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

When I ran Add-Migration in Visual Studio's package manager console it created migration successfully.

What should I do to make to success in command line with dotnet.exe? Am I missing something?

1
1
3/28/2019 4:41:51 PM

Popular Answer

Finally, I found another project that worked for me and difference between it and this was the version of the EntityFramework.

Updating EntityFramework Core from 1.1 to 2.0 fixed my issue.

0
4/1/2019 5:21:59 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow