我应该有几个DBContext [英] How Many DBContext's Should I have

查看:92
本文介绍了我应该有几个DBContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用实体,我目前拥有dbcontext,其中包含每个表.

Using Entity I currently have dbcontext that has every table in it.

我想知道这是否每个人都在做,还是例如每个模块都有一个上下文.对我而言,dbcontext是将模型映射到数据库的连接,并且由于只有一个数据库,因此我只需要一个数据库.

I'm wondering if that's what everyone does, or do you have a context per module for example. To me the dbcontext was a connection to map the models to a database, and since there is only one database, I only need one.

在我走得太远之前,我想看看是否合适.

Before I get too far along I want to see if that's appropriate.

那么每个数据库有1个db上下文还是很多?

So 1 db context per database or many?

推荐答案

我最近也经历了同样的过程,并在该主题上找到了很多有用的资源.这对夫妇非常有帮助:

I went through this same process recently and found some great resources on the subject. Here are a couple that were very helpful:

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