I've got one function app which throws following error when I run it with [email protected]
start
command.
func start
System.Private.CoreLib: Exception while executing function: Test.
Microsoft.EntityFrameworkCore: The type initializer for
'Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor'
threw an exception. Microsoft.EntityFrameworkCore:
The type initializer for
'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
System.Linq: Sequence contains more than one matching element.
Entrypoint
private readonly IRepository _repository;
[FunctionName("Test")]
public async Task TestAsync(
[ServiceBusTrigger(
"%topic%",
"%subscription%",
Connection = "connectionString")]
Message message)
{
var result = await _repository.ToListAsync();
}
It works fine when function app is launched from Visual Studio.
I thought I could get rid of that by directly referencing Microsoft.EntityFrameworkCore
in function app csproj.
Any ideas?
Thanks
FunctionApp.csproj
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus"
Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FirstLib\FirstLib.csproj" />
</ItemGroup>
FirstLib.csproj
<ItemGroup>
<ProjectReference Include="..\SecondLib\SecondLib.csproj" />
</ItemGroup>
SecondLib.csproj
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="3.1.8" />
</ItemGroup>
Visual Studio version
Microsoft Visual Studio Professional 2019
Version 16.10.4
The problem went away when I upgraded Microsoft.EntityFrameworkCore
to 5.0.0
in SecondLib
dependency.
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="5.0.0" />
</ItemGroup>
The TargetFramework
wasn't touched
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With