Simply Adding Entity Framework Core to a basic Azure function application results in an error

放肆的年华 提交于 2020-01-14 02:10:08

问题


It's very simple to describe:

  • 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.

  • Now add the Microsoft.EntityFrameworkCore (3.1.0) package

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: 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.).


回答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

-- Original Answer

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



来源:https://stackoverflow.com/questions/59291143/simply-adding-entity-framework-core-to-a-basic-azure-function-application-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!