EntityFramework Core Unit Testing - SQLite in-memory mode vs. The InMemory provider

.net-core c# entity-framework-core unit-testing

Question

I am in a process of writing unit tests for a project that uses EntityFramework Core and according to the docs I can use SQLite in-memory mode or The InMemory provider to approximate the database context.

The docs states that the SQLite in-memory mode behaves like a relational database and that The InMemory provider does not always behave like a relational database.

As far as I understand the SQLite mode sounds better because it behaves like relational database while the InMemory provider does not, but I guess there is other aspects to consider otherwise noone will use The InMemory provider which sounds a lot worse.

Is there other pros and cons to each approach I should consider before I choose which tool to use?

1
15
7/18/2017 9:46:57 AM

Popular Answer

If your sole purpose is writing Unit Tests, look closely at the boiler plate code needed to create the tests, that could impact your deadlines... I would go with the option that makes me type less code! (The InMemory provider looks simpler).

Look at the samples and decide:

...and of course your project will have Integration Tests, on those you will connect to the real database and do additional checks. That's why for the unit tests my main concern is writing time, not so much how the mock DB behaves

8
9/20/2017 6:07:33 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow