I have a case with a single database defined by a single Entity Framework DbContext.
I have things set up where updating the database is via services. This separates things out nicely and makes it easy to mock the database for the bUnit (Blazor server app) tests.
But I need to accomplish the following:
- Start transaction
- Call PlaceOrder service
- Call UpdateInventory service
- Complete transaction
How can I accomplish this in a way where the outer code does not explicitly use Entity Framework (so I can mock in unit tests)?
The best I've come up with is create MyDbContext and pass that in to each. That works but it feels awkward. I am SQL Server (dev) and Azure SQL Database (production) so a solution that requires SQL Server works for me.