DEV Community

Matheus Rodrigues
Matheus Rodrigues

Posted on • Originally published at on

How To: Use EntityFramework Core In-Memory Database For Unit Testing

You can download this article project on GitHub.

In this post, I’ll show how to use the in-memory feature of Entity Framework core to create unit tests involving the database. Let’s jump right in!

Create unit tests using a real DbContext is a pain because we have to mock the entire context to achieve this. Entity Framework core makes unit tests easier to write by providing us with an in-memory database provider. It creates an in-memory representation of our DbContext, for this reason, we don’t have to worry about mocking the database.

Continue Reading...

Top comments (0)