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

后端 未结 3 535
故里飘歌
故里飘歌 2021-01-02 08:57

I upgraded a .net standard class library from Entity Framework Core 1.1 to Entity Framework 2.0

I am trying to run Add-Migration on an Entity Framework Core Class Li

相关标签:
3条回答
  • 2021-01-02 09:23

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

    0 讨论(0)
  • 2021-01-02 09:24

    Add AutoGenerateBindingRedirects and GenerateBindingRedirectsOutputType to your class library csproj

    e.g.

    <PropertyGroup>
        <TargetFramework>net461</TargetFramework>
    
        ....
    
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
    
    0 讨论(0)
  • 2021-01-02 09:31

    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="cc7b13ffcd2ffffd51" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> ... </configuration>

    0 讨论(0)
提交回复
热议问题