title: EF Core In Memory database data leaking between unit tests
body: <p>I'm trying to mock my EF-Core database by using the in memory provider as described here: <a href="https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory</a>.</p>
  
  <p>I have structured my tests like so:</p>
  
  <pre><code>[Test]
  public async Task PerformTest1() {
    var options = new DbContextOptionsBuilder&lt;MeldingenModel&gt;()
      .UseInMemoryDatabase(nameof(PerformTest1))
      .Options;
    var protos = new List&lt;MeldingPrototype&gt; { ... };
    var meldingen = new List&lt;Melding&gt; { ... };
    using (var seedingcontext = new MeldingenModel(options)) {
  
      seedingcontext.MeldingPrototypes.AddRange(protos);
      seedingcontext.Meldingen.AddRange(meldingen);
      seedingcontext.SaveChanges();
    }
    using (var db = new MeldingenModel(options))
    using (var mock = AutoMock.GetLoose(cgf =&gt; cgf.RegisterInstance(db))) {
  
      // do test
    }
  }
  </code></pre>
  
  <p>The first section is to seed data into the database. Each test has a similar pattern, and each is using <code>nameof(&lt;methodname&gt;)</code> as argument to <code>UseInMemoryDatabase</code>. The way I understand the docstrings on that method, the different string arguments should ensure that all the created databased are separate, but they still seem to be affecting each other. If I run each test in isolation, they all pass, but running them all at once makes them fail. The reason for failure is that seed data from one method is also present during the other tests. </p>
  
  <p>The test-framework I use is nUnit.</p>
  
  <p>Can anyone help me get properly isolated testdatabases?</p>