多个DB上下文并跨上下文连接 [英] Multiple DB Context and join across context

查看:95
本文介绍了多个DB上下文并跨上下文连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是EF Core的新手,我们正试图找出在不同应用程序中组织实体和DBContext的最佳方法。 一个例子是,如果我们是汽车经销商,我们将有一个"销售"。帐户DBContext和"修复"帐户
DBContext。 我们有一个"销售"应用程序以及"修复"的应用。 然而,存在一个需要"销售"的地方。男人需要看一辆交易过的车,看看这里做了什么修理。 在这种情况下,他需要将b $ b加入销售维修。

I am new to EF Core and we are trying to figure out the best way to organize our entities and DBContext across different applications.  An example would be if we were a car dealership, we would have a "sales" account DBContext and a "repair" DBContext.  We have an app for "sales" and an app for "repair".  However, there is one need where the "sales" guy needs to look at at a car that was traded in to see what repairs were done here.  In that case he needs to join sales with repairs.

我的问题是如何在DBContext中加入实体? 如果这是不可能的,那么管理这样的场景的最佳方法是什么,这样你就不会将所有实体放在所有应用程序的同一个DBContext中?

My question is how can you join entities across DBContext?  If this is not possible, then what is the best way of managing scenarios like this so that you don't put all your entities in the same DBContext for all your apps?

推荐答案

您好,

无需为每个表创建DBContext。  DBContext中可以有多个不同的表。

There is no need to create a DBContext for each table. There can be multiple different tables in a DBContext.

问候,

Kyle


这篇关于多个DB上下文并跨上下文连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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