我正在尝试创建迁移,但是失败并显示-f
。来自Value cannot be null. Parameter name: contentRootPath.
和dotnet ef migrations add
的相同错误。
这是完整的详细输出:
dotnet ef migrations script
当我在Visual Studio的程序包管理器控制台中运行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
时,它成功创建了迁移。
我应该怎么做才能使dotnet.exe在命令行中成功?我想念什么吗?
答案 0 :(得分:0)
最后,我找到了另一个对我有用的项目,它与EntityFramework的版本之间是不同的。
将EntityFramework Core从1.1更新到2.0解决了我的问题。