DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Matheus Rodrigues
Matheus Rodrigues

Posted on • Originally published at matheus.ro 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)

🌚 Life is too short to browse without dark mode