【问题标题】:Unable to create migrations. Error MSB1009: Project file does not exist无法创建迁移。错误 MSB1009:项目文件不存在
【发布时间】:2022-02-05 05:08:39
【问题描述】:

我开始使用 VS 代码开发 Asp.net Core Web API。但是当我尝试创建 ef 迁移时,我得到了这个错误:

PS D:\PROJECTS\GrandExchange> dotnet ef --startup-project /API.csproj migrations add IdentityAdded --context Persistence --output-dir Migrations --project /Persistence/Persistence.csproj
MSBUILD : error MSB1009: Project file does not exist.
Switch: D:\Persistence\Persistence.csproj
Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
PS D:\PROJECTS\GrandExchange> 

我的文件夹结构如下:Folder structure

那么问题出在哪里?

【问题讨论】:

    标签: .net entity-framework-core dotnet-cli


    【解决方案1】:

    哦,在别处找到了解决方案。 我只需要在 --project 参数中插入迁移程序集完整路径,如下所示:

    PS D:\PROJECTS\GrandExchange\api> dotnet ef migrations add IdentityAdded --context DataContext --output-dir Migrations --project "D:\PROJECTS\GrandExchange\Persistence\Persistence.csproj"
    

    并从我的主启动项目(如 D:\PROJECTS\GrandExchange\API)执行此命令

    我在那里找到了这个解决方案: https://stackoverflow.com/a/63508741/12959213

    【讨论】:

      猜你喜欢
      • 2018-08-06
      • 2017-04-06
      • 1970-01-01
      • 2021-07-21
      • 2019-06-17
      • 2020-03-30
      • 2017-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多