无法使用 EntityFrameworkCore.Tools 和 AzureFunctions 创建添加迁移

Unable to create add migrations with EntityFrameworkCore.Tools and AzureFunctions

几个小时以来,我一直在尝试 运行 使用 EntityFramework.Core 在 Azure Functions 上进行迁移。它抛出一个错误:

PM> add-migration newmigration
Error:
  An assembly specified in the application dependencies manifest (Test.API.deps.json) was not found:
    package: 'Test.API', version: '1.0.0'
    path: 'Test.API.dll'

为了尝试解决这个问题,我将 .net 核心版本从 2.2.104.Updated Azure Functions SDK 和 EntityFramework 更新到最新的 2.2.300(目前最新) .尝试了不同的 sql 服务器,但仍然没有进展。删除了 bin 和 obj 文件夹 - 运气不好。甚至删除数据包管理器缓存...


更新: 问题是文件夹 bin/debug/netcoreapp2.2 我有另一个文件夹 bin 其中 Test.API.dll 是,但 清单文件 位于文件夹 bin/debug/netcoreapp2.2 中。 如果您从 bin/debug/netcoreapp2.2 的内部容器中剪切并粘贴所有内容,一切正常。此外,如果您转到清单文件并将整个路径显式添加到 Test.API.dll,它会起作用。 但它仍然需要手动工作,任何想法如何让它自动识别正确的路径 Test.API.dll?

@jeffhollan 在这里找到了可用的解决方案: https://github.com/jeffhollan/functions-csharp-entityframeworkcore/blob/master/functions-csharp-entityframeworkcore/functions-csharp-entityframeworkcore.csproj

在您的 csproj 中,添加以下行:

   <Target Name="PostBuild" AfterTargets="PostBuildEvent">
     <Exec Command="copy /Y &quot;$(TargetDir)bin$(ProjectName).dll&quot;
 &quot;$(TargetDir)$(ProjectName).dll&quot;" />   
 </Target>

希望对您有所帮助!