The Code Blogger - .NET EF Core – Unit Testing EF Core ...
thecodeblogger.com › 2021/12/09 › net-ef-core-unitDec 9, 2021 · I already have discussed briefly about InMemory database provider for EF Core in one of the past articles. That article was a small step by step guide to explain how InMemory provider can be used. This article is kind of an extension to the previous article. In this article, we are going to have look at which options are available for unit testing the EF Core repositories and how can we decide which option is better for our project.
Testing without your Production Database System - EF Core
learn.microsoft.com › en-us › efNov 8, 2022 · In normal usage, EF Core's DbContext opens and closes database connections as needed - every time a query is executed - to avoid keeping connection for unnecessarily long times. However, with in-memory SQLite this would lead to resetting the database every time; so as a workaround, we open the connection before passing it to EF Core, and arrange for it to be closed only when the test completes:
Overview of testing applications that use EF Core - EF Core
learn.microsoft.com › en-us › efNov 23, 2022 · For a testing approach that allows you to use a reliable test double for all the functionality of your production database system, it's possible to introduce a repository layer in your application. This allows you to exclude EF Core entirely from testing and to fully mock the repository; however, this alters the architecture of your application in a way which could be significant, and involves more implementation and maintenance costs.