❔ Which database for integration test using db transactions
Hi there,
I am coding my integration test project.
And I want to test the transactionnal aspect of two functions called.
I installed sqllite inmemory on my project. And set it in memory
I well mocked my the last function called before the commit and do a
.throw(new Exception());
and context.rollbackTransaction()
in the catch.
But I get a "no such table : Buy" when I run my test. I don't understand why I will have to do migration on a inmemory database. For me, it's a no-sense.
So, what do you advise me to use for my test ? in prod I use sql server8 Replies
Use SQL Server for integration tests as well, then
your sqlite db still needs tables
and you need to keep a connection to the sqlite db open if its in memory, or it will be gone, when you open another connection
So, how to apply migration to an in-memo sqllite db. If my migrations are in another project. And that my integration test project doesn't have appsetting....
then ? ^^
no idea how appsettings are relevant to this. but you apply migrations as you usually do, by pointing ef core at the assembly to use
Using a Separate Migrations Project - EF Core
Using a separate migration project for managing database schemas with Entity Framework Core
Because , i was thinking that dotnet ef update database read the C# code who read a string connection
but may be it works with the 'var connection = new SqliteConnection("DataSource=:memory:");'
do you understand what the
memory
bit means? it means, as soon as all connection to that database are closed, the database will be gone
tldr: once your update command completes, your sqlite db will be goneWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.