从不同的DbContext - 模型的表中加入 [英] Join on tables from different DbContext - model first

查看:842
本文介绍了从不同的DbContext - 模型的表中加入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有EF6.0的应用程序中,我有两个由模型创建的DbContext, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆