dotnet ef migrations: значение не может быть нулевым. Имя параметра: contentRootPath - PullRequest
1 голос
/ 28 марта 2019

Я пытаюсь создать миграцию, но она не работает с Value cannot be null. Parameter name: contentRootPath.. Одна и та же ошибка от dotnet ef migrations add и dotnet ef migrations script.

Вот полный подробный вывод:

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

Когда я запустил Add-Migration в консоли диспетчера пакетов Visual Studio, он успешно создал миграцию.

Что я должен сделать, чтобы добиться успеха в командной строке с dotnet.exe? Я что-то упустил?

1 Ответ

0 голосов
/ 01 апреля 2019

Наконец, я нашел другой проект, который работал для меня, и разница между ним и этой версией была EntityFramework.

Обновление EntityFramework Core с 1.1 до 2.0 исправило мою проблему.

...