首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >dotnet ef迁移:值不能为null。参数名称: contentRootPath

dotnet ef迁移:值不能为null。参数名称: contentRootPath
EN

Stack Overflow用户
提问于 2019-03-29 00:41:52
回答 1查看 1.2K关注 0票数 1

我正在尝试创建迁移,但是使用Value cannot be null. Parameter name: contentRootPath.失败了。来自dotnet ef migrations adddotnet ef migrations script的相同错误。

下面是完整的详细输出:

代码语言:javascript
运行
复制
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

当我在Visual Studio的包管理器控制台中运行Add-Migration时,它成功地创建了迁移。

我应该怎么做才能在命令行中使用dotnet.exe成功?我是不是遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2019-04-01 13:22:00

最后,我发现了另一个适合我的项目,以及它与EntityFramework版本的区别。

将EntityFramework核心从1.1更新到2.0解决了我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55402849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档