Azure functions with Entity Framework Core 2.0 and .NET 4.7

.net-core azure azure-functions entity-framework-core


I am running into issues running Entity Framework queries from within an Azure Function. The same code runs perfectly fine from a Console Application.

Here is the exact error I am getting:

"Could not load file or assembly 'System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.":"System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"

Notice how it can't find the right version. Could this be an issue?

Here is my setup: 1. My Class Libraries that contain the Data Models are using .NET Standard 2.0 and .NET 4.7 as Target Frameworks. I manually changed the project to have the following: <TargetFrameworks>netstandard2.0;net47</TargetFrameworks>

  1. The Azure Functions target .NET 4.7
  2. After reviewing the issue, I also manually installed the ValueTuple DLL from Nuget and I still am not seeing

Is there anything that I am missing? Would love to hear if someone is facing a similar issue.

Thank You, Anup

9/11/2017 1:04:09 PM

Accepted Answer

Azure Functions doesn't currently support .Net Core 2 (more specifically, .Net Standard 2.0), however, it seems like the team is actively working on getting this support out...see here: Port runtime to .NET Core

Runtime will be ported to target Netstandard 2.0.

My suggestion is that if you really need to use EntityFramework, then perhaps you could drop down to EF6, which would be compatible with .Net 4.7.

Alternatively, depending on your complexity, you could also completely do away with using EF and simply write your commands using SqlConnection/SqlCommands

using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString)) {
  var query = "SELECT * FROM Users"; // example query

  using (var command = new SqlCommand(query, connection)) {
9/7/2017 5:11:44 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow