System.IO.FileLoadException while using EntityFramework Core 2.0

entity-framework entity-framework-core mstest unit-testing

Question

I am using the In memory provider in a .Net 461 unit test project. I am using VS 2017.

   var contextOptionsBuilder = new DbContextOptionsBuilder();
            contextOptionsBuilder
             .UseInMemoryDatabase("testmethod1");
            var ctx = new ConfigStoreDbContext(contextOptionsBuilder.Options);

The packages.config contains the following package.

  <package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />

Here is the stack trace.

Test Name:  TestMethod1
    Test Outcome:   Failed
    Test Duration:  0:00:01.1170206

    Result StackTrace:  
    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState entityState, Boolean forceStateWhenUnknownKey)
       at Microsoft.EntityFrameworkCore.DbContext.SetEntityState(InternalEntityEntry entry, EntityState entityState)
       at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity](TEntity entity, EntityState entityState)
       at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity](TEntity entity)
       at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Add(TEntity entity)
       at Microsoft.ProjectConfig.Configuration.Sql.SqlConfigurationWriter`4.<AddOrUpdateSettingTypeImplAsync>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at Microsoft.ProjectConfig.Configuration.ConfigurationWriterBase`4.<AddOrUpdateSettingTypeAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at Microsoft.ProjectConfig.Configuration.UnitTests.UnitTest1.<TestMethod1>d__0.MoveNext() in C:\Repos\ProjectConfig\UnitTestProject1\UnitTest1.cs:line 25
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.ThreadOperations.ExecuteWithAbortSafety(Action action)
    Result Message: 
    Test method Microsoft.ProjectConfig.Configuration.UnitTests.UnitTest1.TestMethod1 threw exception: 
    System.IO.FileLoadException: 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)
1
0
9/6/2017 8:43:06 PM

Popular Answer

This issue is documented in the Entity Framework repository, here: https://github.com/aspnet/EntityFrameworkCore/issues/9046.

1
9/6/2017 9:22:05 PM


Related Questions





Related

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