Azure Functions 1.0.7 giving Could not load file or assembly error with EF Core 2

3

I'm trying to move some functionality to Azure Functions. Created a project for EF Core 2 code, and referenced it to the Azure Functions project. Added the EF Core+SQLServer nugget packages to the Azure Functions project. When the function attempts to execute, this is the errors in the screen. I can see that the Microsoft.EntityFrameworkCore assembly is in the same directory as our azure functions dll.

Can anyone shed some light on why it's not finding it and how to fix this?

[1/3/2018 6:49:56 AM] A ScriptHost error has occurred
[1/3/2018 6:49:56 AM] Exception while executing function: Accounting. AS.Jobs: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[1/3/2018 6:49:56 AM] Exception while executing function: Accounting
[1/3/2018 6:49:56 AM] Exception while executing function: Accounting. AS.Jobs: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[1/3/2018 6:49:56 AM] Function completed (Failure, Id=56ba500b-7c3a-45c1-a9eb-8be4d52d1592, Duration=159ms)
[1/3/2018 6:49:56 AM]
[1/3/2018 6:49:56 AM] Executed 'Accounting' (Failed, Id=56ba500b-7c3a-45c1-a9eb-8be4d52d1592)
[1/3/2018 6:49:56 AM] System.Private.CoreLib: Exception while executing function: Accounting. AS.Jobs: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[1/3/2018 6:49:56 AM]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '56ba500b-7c3a-45c1-a9eb-8be4d52d1592'
[1/3/2018 6:49:56 AM] System.Private.CoreLib: Exception while executing function: Accounting. AS.Jobs: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.  

Update: 1/3/2018
I have VS 2017 15.5.2 installed, and I am building this in VS.

Here is the output of the function host when I run it from VS.

[1/4/2018 3:47:03 AM] Host configuration file read:
[1/4/2018 3:47:03 AM] {
[1/4/2018 3:47:03 AM] }
[1/4/2018 3:47:04 AM] Generating 1 job function(s)
[1/4/2018 3:47:04 AM] Starting Host (HostId=jlt03-962556955, Version=2.0.11353.0, ProcessId=21200, Debug=False, Attempt=0, FunctionsExtensionVersion=)
[1/4/2018 3:47:04 AM] Found the following functions:
[1/4/2018 3:47:04 AM] Jobs.Accounting.Run
[1/4/2018 3:47:04 AM]
Listening on http://localhost:7071/  
azure
entity-framework-core
azure-functions
azure-web-app-service
asked on Stack Overflow Jan 3, 2018 by John C • edited Jan 4, 2018 by John C

2 Answers

3

So after much much more searching, I came across this GitHub posted issue. It is the exact same issue that I am seeing here. Apparently it is a issue with Azure Functions 1.0.7 and EF Core 2.0.1.

I had to role back AF back to 1.0.6 AND I also had to role EF Core back to 2.0.0. Afterwards the function executed as expected.

I will be monitoring the GitHub issue and update this answer once it is confirmed to be fixed.

Update
This is now fixed with Azure Functions Core Tools 2.1.0 release.
https://github.com/Azure/app-service-announcements/issues/109

answered on Stack Overflow Jan 4, 2018 by John C • edited May 24, 2018 by John C
0

what worked for me was to delete all folders under bin folder and build the app!!

answered on Stack Overflow Jan 31, 2018 by azaki

User contributions licensed under CC BY-SA 3.0