从不同的DbContext - 模型的表中加入 [英] Join on tables from different DbContext - model first
问题描述
Schema1.DbContext1
和 Schema2.DbContext2
。 现在我需要在两个实体上进行加入, EntityA
从 Schema1.DbContext1
和 EntityB
从 Schema2.DbContext2
。
我该怎么做?
如果可以使用存储过程,案例为它proc可以跨数据库加入数据库级的两个实体。无论哪个数据库适合,您都可以在实体模型中映射该proc并使用它。我说'如果可以',因为我看到商店禁止所有的SP赞成只有EF。
In an app with EF6.0, I have two DbContext's created by model first, Schema1.DbContext1
and Schema2.DbContext2
.
Now I need to do a join on two entities, EntityA
from Schema1.DbContext1
and EntityB
from Schema2.DbContext2
.
How can I do this?
If you can use stored procedures, this is a case for it. The proc can join the two entities at the database level across databases. Whichever db is appropriate, you can then map that proc in your entities model and use it. I say 'if you can' because I've seen shops that prohibit all SP's in favor of only EF.
这篇关于从不同的DbContext - 模型的表中加入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!