简体   繁体   English

Entity Framework Core 导致无法加载 netstandard

[英]Entity Framework Core results in could not load netstandard

I am running Azure function with a Http trigger using .NET Core 3.1 in Visual Studio 2019 Version 16.5.0 Preview 1 and I am getting the following errors:我在 Visual Studio 2019 版本 16.5.0 预览版 1 中使用 .NET Core 3.1 运行带有 Http 触发器的 Azure 函数,我收到以下错误:

The 'HttpTriggerCSharp' function is in error: Unable to load one or more of the requested types. “HttpTriggerCSharp”函数出错:无法加载一种或多种请求的类型。 [12/25/2019 9:32:30 PM] [12/25/2019 晚上 9:32:30]

Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.无法加载文件或程序集“netstandard,Version=2.1.0.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”。 The system cannot find the file specified.该系统找不到指定的文件。 [12/25/2019 9:32:30 PM] [12/25/2019 晚上 9:32:30]

Microsoft.Azure.WebJobs.Host: Error indexing method 'HttpTriggerCSharp'. Microsoft.Azure.WebJobs.Host:索引方法“HttpTriggerCSharp”时出错。 Microsoft.Azure.WebJobs.Host: cannot bind parameter 'log' to type ILogger. Microsoft.Azure.WebJobs.Host:无法将参数“log”绑定到 ILogger 类型。 Make sure the parameter type is supported by the binding.确保绑定支持参数类型。 If you're using binding extensions (eg Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (eg builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).如果您使用绑定扩展(例如 Azure Storage、ServiceBus、Timers 等),请确保您已在启动代码(例如 builder.AddAzureStorage()、builder.AddServiceBus() 中调用了扩展的注册方法)、builder.AddTimers() 等)。

The error appears when I installed the nuget package for the Microsoft.EntityFrameworkCore.SqlServer .当我为Microsoft.EntityFrameworkCore.SqlServer安装 nuget 包时出现错误。

Any idea how to fix this?知道如何解决这个问题吗?

It turned out I was running v2 of the Azure Function runtime and when I changed it to v3 in the FunctionApp1.csproj file it started to work.结果证明我正在运行 Azure Function 运行时的 v2,当我在 FunctionApp1.csproj 文件中将其更改为 v3 时,它开始工作。

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>

Assuming Solution 1.假设解决方案1。

Install latest .NET Core SDK安装最新的 .NET Core SDK

Assuming Solution 2.假设解决方案 2。

Delete the bin/ and obj/ folders and rebuild the solution.删除 bin/ 和 obj/ 文件夹并重建解决方案。

Assuming Solution 3.假设解决方案 3。
unistall installed package and reinstall卸载已安装的软件包并重新安装

dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 3.1.0

.NET Core 2.0 and later, restore is done automatically with dotnet build and dotnet run, but do it manually some time helps .NET Core 2.0 及更高版本,还原是通过 dotnet build 和 dotnet run 自动完成的,但手动执行一段时间会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM