Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jernejk/mixedefcoreunittesting
When doing unit tests for EF Core, we can use in-memory-database to test functionalities but sometimes we needs to use SQL features. That's where SQLite comes into play.
https://github.com/jernejk/mixedefcoreunittesting
dotnetcore3 efcore in-memory-database samples sqlite unit-testing
Last synced: 2 days ago
JSON representation
When doing unit tests for EF Core, we can use in-memory-database to test functionalities but sometimes we needs to use SQL features. That's where SQLite comes into play.
- Host: GitHub
- URL: https://github.com/jernejk/mixedefcoreunittesting
- Owner: jernejk
- Created: 2018-02-19T08:45:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-01T07:18:16.000Z (about 1 year ago)
- Last Synced: 2024-05-02T05:13:53.041Z (10 months ago)
- Topics: dotnetcore3, efcore, in-memory-database, samples, sqlite, unit-testing
- Language: C#
- Homepage: https://jkdevblog.wordpress.com/2018/02/27/net-core-complex-ef-core-unit-testing/
- Size: 3.03 MB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**UPDATE December 2023:** Updated for .NET 8! While the talk is originally for EF Core 2.1, majority of the points as well as code is still relevant in EF Core 8!
# Mixed EF Core unit testing with in-memory and SQLite DBs
When doing unit tests for EF Core, we can use in-memory-database to test functionalities but sometimes we needs to use SQL features. That's where SQLite comes into play.
When running the tests, 2 tests will fail:
- InMemoryDbTests.ShouldFailWhenIncludeIsNotUsed
- InMemoryDbTests.ShouldNotBeAbleToExecuteSqlThis is intended to demonstrate when and why EF Core In-Memory DB provider won't work and SQLite is a better choice.
## Original content for this source code
Original blog post: [.NET Core complex EF Core unit testing](https://jkdev.me/ef-core-unit-tests/) (February 2018)
[](https://www.youtube.com/watch?v=PppmuvsFO78)
## Additional content on C# unit tests and EF Core
[](https://www.youtube.com/watch?v=PppmuvsFO78)