无法创建迁移。错误 MSB1009:项目文件不存在

Unable to create migrations. Error MSB1009: Project file does not exist

我开始使用 VS 代码开发 Asp.net 核心网络 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

那么问题出在哪里呢?

哦,在别处找到了解决办法。 我只需要在 --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)执行此命令

我在那里找到的这个解决方案: