Efcore: Unable to create migrations with target framework 461

Created on 29 Aug 2017  路  8Comments  路  Source: dotnet/efcore

dotnet ef migrations add new_migration

Exception message:
Could not load file or assembly 'System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Steps to reproduce

https://github.com/severisv/ef-core-bug-repro
dotnet restore
dotnet ef migrations add new_migration

Further technical details

EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: cmd

closed-question

Most helpful comment

Have you tried adding this to app.config:

<assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
  </dependentAssembly>
</assemblyBinding>

Or this: https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/

All 8 comments

Have you tried using the vs pmc tools instead?

I have the same error message when trying to use EF Core 2.0.0 in an Azure Functions project targeting net461.

mscorlib: Exception while executing function: Function1. Microsoft.EntityFrameworkCore.Relational: Could not load file or assembly 'System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

I tried adding the latest System.ValueTuple package reference to the project and it didn't fix the problem.

Have you tried adding this to app.config:

<assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
  </dependentAssembly>
</assemblyBinding>

Or this: https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/

The solution in the blog post did fix the issue. The app.config binding redirects don't seem to work in a Function app project.
Thank you

Can't get migrations through PMC to work (following this guide): Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet.

The assembly redirect workaround isn't doing the trick either, though I'm not sure I'm doing it right. What I tried was creating a file named app.config in the project directory and paste the xml elements. Does it require a certain structure?

severisv in the article you have an example with the app.config

<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>

Now it works, thanks!

@severisv Looks like in the repro above the EF tools are not installed. This is likely why the PMC commands were not working.

Closing since it seems things are working for people now. The need to do the binding redirect is something we will follow up on more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dragnilar picture dragnilar  路  236Comments

rowanmiller picture rowanmiller  路  85Comments

econner20 picture econner20  路  97Comments

vsfeedback picture vsfeedback  路  98Comments

rowanmiller picture rowanmiller  路  101Comments