'System.ValueTuple, Version=0.0.0.0 required for Add-Migration on .NET 4.6.1 Class Library

北城余情 提交于 2019-12-03 12:31:28

Add AutoGenerateBindingRedirects and GenerateBindingRedirectsOutputType to your class library csproj

e.g.

<PropertyGroup>
    <TargetFramework>net461</TargetFramework>

    ....

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

I had the same problem, and it got fixed after installing .NET 4.7.1 framework

Starting with the following lovely error because StructureMap failed to instantiate the dbContext for Entity Framework Core:

An error occurred when trying to create a controller of type '[NameOfController]'. Make sure that the controller has a parameterless public constructor.

I had to do some more work than the answers supplied here to get it to work in .NET Framework 4.6.2:

Install nugets (source: https://github.com/neuecc/MessagePack-CSharp/issues/46)

  • System.Threading.Tasks.Extensions (I used latest v4.5.2)
  • System.ValueTuple (I used old 4.3.1)

Add to .proj that contained repositories (source: https://stackoverflow.com/a/45978409/581414)

<PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup>

And to web.config (sources: various)

<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>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!