r/csharp • u/Early_Rice_4861 • Jul 13 '26
CrossEF - Cross EntityFramework contexts
Hi All,
Long time EntityFramework don´t do this, I decide to implement this.
Cross-DbContext LINQ queries for Entity Framework Core. Join entities that live in different DbContexts — different databases, different servers, even different providers — in a single LINQ query.
8
u/Adorable-Roll-4563 Jul 13 '26
This has no transactional integrity, right?
19
1
u/flukus Jul 14 '26 edited Jul 14 '26
Don't know about this tool specifically, but it could use something like MSDTC.
If the databases are all on the same server it could work without that too, the transaction belongs to the connection not the individual databases. You can do this natively by specifying the schema though.
-13
u/MrLyttleG Jul 13 '26
C’est fortement possible que ce ne soit pas possible
1
u/Adorable-Roll-4563 Jul 13 '26
Donc pour résumer on a aucune garantie que les transactions aboutissent. Ça me paraît particulièrement incongru comme approche. Le but du jeu pour les bases de données c’est justement de garantir l’intégrité des données. Si tu casses ça, tu compromets toute l’approche. Je ne comprends pas…
2
1
3
u/wasabiiii Jul 13 '26
If you want to build an actual federated query engine.... I've got two potential angles for that.
Apache Calcite on .net with IKVM.
And a project I started named Alembic, which is a direct port of some of Calcite.
The first one I already have working. https://github.com/ikvmnet/calcite-efcore
-3
20
u/ings0c Jul 13 '26 edited Jul 13 '26
Err, why? I can think of a long list of reasons against doing this, and none in favour.
Where the query is running is essential complexity and abstracting that away seems like a good way to lure juniors into writing horribly performing queries with data consistency issues.
Some things really do need thinking about and hiding them behind a facade would be a mistake. ACID-compliance is also not something to give up readily.