Azure 函数与 EntityFramework + DI

标签 azure dependency-injection entity-framework-core azure-functions

Microsoft.NET.Sdk.Functions 版本 3.0.4 似乎破坏了 EntityFrameworkCore 的 DI。

在 3.0.3 中,我可以在 DI 中添加 InMemoryDatabase 并在我的函数中使用它,但升级到 3.0.4 会中断:

Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type 'AzureFunction.Contexts.TestContext' while attempting to activate 'AzureFunction.TestFunction'.

我制作了带有图片的重现项目(参见图片/)here

最佳答案

是的,这是 Microsoft.NET.Sdk.Functions 版本 3.0.4 中的问题。

您可以在 3.0.5 上尝试一下几个小时前发布,DI 问题已修复。

关于Azure 函数与 EntityFramework + DI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60549618/

相关文章:

entity-framework-core - EF Core 多个左连接

asp.net-core - 在 Entity Framework Core 3.1 中使用 DateTime 作为 SQL 时间列

c# - 如何使用 Azure Devops Services Rest API 更新 Azure Devops 中测试用例的 "Area Path"

c# - Azure Functions 中的静态与非静态类和方法

c# - .NET CORE依赖注入(inject)将参数传递给构造函数

c# - 为什么 .NET Core 选项的配置不适用于泛型类型参数?

c# - 'CustomerId' 操作的结果中不存在所需的列 'FromSql'

Azure逻辑应用程序: Why FTP Connector delays to Identify files over FTP connector?

Azure 证书分配给虚拟机

spring - 将依赖注入(inject)与 Play 框架一起使用的示例用例