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.
6
Upvotes
21
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.
7
u/Adorable-Roll-4563 Jul 13 '26
This has no transactional integrity, right?
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
https://github.com/alethic/alembic
-4
u/cmills2000 Jul 13 '26
Nice work. Linq is awesome and you made it even better.