PawelGerr / Thinktecture.EntityFrameworkCore

These libraries extend Entity Framework Core by a few features to make it easier to work with EF and for easier integration testing or to get more performance in some special cases.
https://dev.azure.com/pawelgerr/Thinktecture.EntityFrameworkCore
BSD 3-Clause "New" or "Revised" License
66 stars 17 forks source link

How to deal with InMemoryDatabase used for tests #25

Closed buthomas closed 2 years ago

buthomas commented 2 years ago

Hi

I'm currently investigating to use the CollectionParameters and/or Temp-Table feature in our project. Unfortunately we have a lot of tests that use the InMemoryDatabase. As far as I can see, there is no support for that DB provider. Is that correct? Do you have any suggestions how to deal with this situation?

One way might be to switch the tests to use SQLite. But then CollectionParameters aren't supported as well.

Thanks a lot.

PawelGerr commented 2 years ago

Currently, the temp tables are implemented for sqlite and sql server only, but I can implement the missing components for in-memory provider yourself. I didn't add support for in-memory provider because I'm using sqlite for my tests.

Alas, the collection parameters are supported with sql server only, there is no such thing in sqlite. If you have some ideas, then I'd like to know them :) But, ... 1) you can use temp tables as a workaround, if you switch to sqlite. For that you will need your own abstraction for definition/creation of collection parameters. By having an abstraction you can use the real methods (i.e. the ones for sql server) in production, otherwise you create a temp table. 2) or, you implement the missing components for in-memory provider.

buthomas commented 2 years ago

Thanks for you quick response. That's pretty much what I expected.