只是将Entity Framework Core添加到基本Azure函数应用程序中会导致错误 [英] Simply Adding Entity Framework Core to a basic Azure function application results in an error

查看:108
本文介绍了只是将Entity Framework Core添加到基本Azure函数应用程序中会导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

描述非常简单:

  • 使用Visual Studio 2019(16.4.1)中的"Azure函数"模板创建新的解决方案.
  • 将TargetFramework更改为".NET Core 3.1".
  • 它将使用Microsoft.NET.Sdk.Functions(1.0.29)创建.
  • 将其更新到最新版本(3.0.1).
  • 它不起作用,因为现在我们将需要其他一些nuget软件包:
    • Microsoft.Azure.WebJobs.Core(3.0.14)
    • Microsoft.Azure.WebJobs.Extensions.Http(3.0.2)
    • Create a new solution using the "Azure Functions" template from Visual Studio 2019 (16.4.1).
    • Change the TargetFramework to ".NET Core 3.1".
    • It will be created with Microsoft.NET.Sdk.Functions (1.0.29).
    • Update it to the latest version (3.0.1).
    • It will not work, because now we will need some other nuget packages:
      • Microsoft.Azure.WebJobs.Core (3.0.14)
      • Microsoft.Azure.WebJobs.Extensions.Http (3.0.2)

      这时,应用程序在模拟器中运行.只需启动调试器,控制台窗口就会显示一切正常.

      At this moment, the application runs in the emulator. Just start the debugger, and the console window shows that everything is fine and working.

      现在添加Microsoft.EntityFrameworkCore(3.1.0)程序包

      Now add the Microsoft.EntityFrameworkCore (3.1.0) package

      在这一点上,我们没有碰到任何代码,我们只是添加了给定nuget软件包的最新版本,还设置了最新的目标框架.尽管如此,在启动带有或不带有调试器的仿真器时,Azure Functions应用程序不再起作用,并抛出此错误:

      At this point, we didn't touch any line of code, and we just added the latest versions of the given nuget packages, also setting the latest target framework. Nonetheless, the Azure Functions application doesn't work anymore, throwing this error, when starting the emulator with or without the debugger:

      Microsoft.Azure.WebJobs.Host:错误索引方法'Function1'.
      Microsoft.Azure.WebJobs.Host:无法将参数"log"绑定到ILogger类型.确保绑定支持参数类型".如果使用绑定扩展(例如Azure存储,ServiceBus,Timer等),请确保已在启动代码中调用了扩展的注册方法(例如builder.AddAzureStorage(),builder.AddServiceBus( ),builder.AddTimers()等).

      Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'.
      Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type ILogger. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

      推荐答案

      更新:刚刚测试并发布了3.1.0的更新-我将检查我的项目,并尝试确定您是否遇到了其他冲突依赖关系-但这可以与3.1.0和netcoreapp3.1一起使用

      Update: Just tested and pushed an update for 3.1.0 - I'd check out my project and try to figure out if you are pulling in some other conflicting dependencies - but that is working with 3.1.0 and netcoreapp3.1

      https://github.com/jeffhollan/functions-chsarp-entitycore-3

      -原始答案

      已使用实体核心3.0.1进行此操作.尚未尝试使用3.1.0,但可以稍后检出.现在应该可以

      Had this working with entity core 3.0.1. Haven’t yet tried with 3.1.0 but can check out later. For now this should work

      这篇关于只是将Entity Framework Core添加到基本Azure函数应用程序中会导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆