Skip to content

Instantly share code, notes, and snippets.

@mirmostafa
Created August 30, 2021 15:45
Show Gist options
  • Save mirmostafa/028177d09dca9a1ef23cf78456c235d3 to your computer and use it in GitHub Desktop.
Save mirmostafa/028177d09dca9a1ef23cf78456c235d3 to your computer and use it in GitHub Desktop.
In-Memory Mock DbContext for UnitTesting
var options = new DbContextOptionsBuilder<MyDbContext>
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
var context = new MyDbContext(options);
context.Database.EnsureCreated();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment