标识dbcontext对另一个dbcontext的引用 [英] Identity dbcontext reference to another dbcontext

查看:105
本文介绍了标识dbcontext对另一个dbcontext的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有两个数据库上下文。一个用于基于用户的.Net核心身份,另一个用于产品和订单等。该方案是,用户通过.Net核心身份可以登录,将产品添加到购物车并完成订单。因此,需要从标识用户dbcontext到包含订单和产品表的另一个dbcontext的外键。我想在两个单独的dbcontext中包含用户和产品/订单。所以我的问题是如何解决这个问题?拥有两个dbcontext还是将所有内容合而为一完全是个好主意?

I have two db contexts in my project. One for users based .Net core identity and another for products and orders etc. for a webshop. The scenario is that a user via .Net core identity can log in, add product to shopping cart and complete an order. Therefor a need to have a foreign key from the identity user dbcontext to the other dbcontext containing the orders and product tables. I would like to have the users and the products/orders in two seperate dbcontext. So my question is how to go about this issue? Is it at all a good idé to have two dbcontext or just have everything in one? Does entity framework have support for this buildt in?

预先感谢!

推荐答案

我正在寻找以下解决方案: https://stackoverflow.com/a/48624628/432074
不必使多个数据库上下文复杂化。

Im going for the following solution: https://stackoverflow.com/a/48624628/432074 There is no need to overcomplicate things with multiple db contexts.

这篇关于标识dbcontext对另一个dbcontext的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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