I am trying to use the EF7 InMemory provider for unit tests, but the persistent nature of the InMemory database between tests is causing me problems.
The following code d
Simply change your code definition of DbContextOptionsBuilder to be like following :
var databaseName = "DatabaseNameHere";
var dbContextOption = new DbContextOptionsBuilder()
.UseInMemoryDatabase(databaseName, new InMemoryDatabaseRoot())
.Options;
new InMemoryDatabaseRoot() creates a new database without the issue of Id's persisting. So you don't need now for :
[TestCleanup]
public void Cleanup()
{
_context = null;
}