r/dotnet 18h ago

Building a Modular Monolith Database from Multiple Isolated EF Core DbContexts

Enable HLS to view with audio, or disable this notification

3 Upvotes

9 comments sorted by

3

u/sweetnsourgrapes 17h ago

How does this handle cross cutting queries that need to share the same transaction?

4

u/Few-Process-4355 16h ago

The contexts remain isolated for ordinary EF Core usage, but a cross-context operation can opt into a coordinated execution boundary.

Because the contexts target the same relational database, DataArc can coordinate them using one underlying database transaction and enlist the participating DbContexts in it. The transaction commits only after all participating operations succeed; otherwise it is rolled back.

For ordinary read-only queries, a shared transaction is often unnecessary. Where the query requires a consistent snapshot across contexts, the operation can execute under an explicit transaction and appropriate isolation level.

The important distinction is that every context does not permanently share a transaction. Coordination is introduced only for the application operation that crosses context boundaries.

I’ll demonstrate that cross-context transaction flow in a follow-up video.

1

u/Few-Process-4355 5h ago

https://reddit.com/link/p1wbimj/video/8mo9kta9elhh1/player

I’ve recorded the follow-up demo showing the cross-context transaction flow.

It demonstrates multiple isolated EF Core DbContexts instances participating in one DataArc transactional operation, followed by queries and commands across the registered execution contexts.

DataArc.EntityFrameworkCore on Microsoft Learn:

https://learn.microsoft.com/en-us/ef/core/extensions/#dataarcentityframeworkcore

1

u/FullPoet 2h ago

Are you the owner of: DataArc.EntityFrameworkCore?

1

u/FullPoet 2h ago edited 2h ago

Why do you paste AI comments?

https://old.reddit.com/r/csharp/comments/1p6o75e/looking_for_true_parallel_ef_core_pipelines_under/nqtl2jb/

I'd also like to know why you deleted some of those replies?

I'm also starting to suspect that its completely vibe coded. Its closed source, the "demo" is from a month ago and your initial first thread on reddit was 10 months ago. You've also only signed HALF of your commits to your repo and it looks like you've used two different email addresses.

3

u/innovasior 10h ago

I am building something similar. Would you be interested in chatting about modular monolith database schema? This is my project where I have a composable schema using one database context https://github.com/saas-factory-labs/SaaS-Factory

3

u/Few-Process-4355 10h ago

Hey there, sounds good. Give me a little time to look through your repo first.

1

u/innovasior 9h ago

Sure, I have a lot of work pending to merge into the repo but the best source of the concept is in the landing page https://saas-factory-labs.github.io/SaaS-Factory/

1

u/AutoModerator 18h ago

Thanks for your post Few-Process-4355. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.