Created
August 30, 2021 15:45
-
-
Save mirmostafa/028177d09dca9a1ef23cf78456c235d3 to your computer and use it in GitHub Desktop.
In-Memory Mock DbContext for UnitTesting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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