I am trying to unit test a project of mine which uses ASP identity (EF core) within VS2017.
The issue I have is when I'm creating my DB context using EF cores in memory it blows up with the following Error -
Message: System.IO.FileLoadException : Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I'm using the following nuget packages
Rest are default xunit packages you get when creating the project.
Any help would be greatly appreciated, spend many hours trying to work out whats going wrong :/
This is the Unit Test Code:
public class TestDbContext : IdentityDbContext<User>
{
public TestDbContext(DbContextOptions<TestDbContext> options) : base(options)
{
}
}
public class User : IdentityUser
{
}
[Fact]
public void Test1()
{
var builder = new DbContextOptionsBuilder<TestDbContext>();
builder.UseInMemoryDatabase();
var context = new TestDbContext(builder.Options);
}
Upgrading to latest version of Microsoft.NET.Test.Sdk
solves the problem.
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />