我在.Net 461单元测试项目中使用内存提供程序。我正在使用VS 2017.
var contextOptionsBuilder = new DbContextOptionsBuilder();
contextOptionsBuilder
.UseInMemoryDatabase("testmethod1");
var ctx = new ConfigStoreDbContext(contextOptionsBuilder.Options);
packages.config包含以下包。
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
这是堆栈跟踪。
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)
答案 0 :(得分:1)
此问题记录在Entity Framework存储库中,此处为:https://github.com/aspnet/EntityFrameworkCore/issues/9046。