I am struggling to decide on the best approach for using my database in my unit tests. I am using XUnit for the tests and my database model is code first with entity framework.
The options I have are InMemory and Real Database, both scaffolded by the entity framework context.
Both seem to have issues though:
InMemory - Good because it can spin up database instances and destroy them fast in memory. Bad because it doesn't find native SQL bugs and can't test functions that run raw SQL commands.
Real - Good because it can find native SQL bugs and test functions that run raw SQL commands. Bad because DbContext is not thread safe and and XUnit runs tests asynchronously which means I would need to spin up a new real database for each test (timely, and messy).
Which is the preferred solution here? Both seem to have pros and cons. Is there a best solution here I am missing?