实体框架 - 如何管理不同数据库中的表,但在同一台服务器上? [英] Entity Framework - how to manage tables in different databases but on the same server?
本文介绍了实体框架 - 如何管理不同数据库中的表,但在同一台服务器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用SQL Server 2008。
I am using SQL Server 2008.
看起来好像在EF中,每个数据库都需要一个不同的实体上下文。在数据库之间加入表格意味着必须允许这样做是不方便的,并且使我更容易将所有内容放在一个数据库中。
It seems as though in EF I need a different entity context for each database. Joining tables between databases means having to allow for this which is inconvenient and makes it more likely that I would simply put everything in one database.
我错过了什么?确定EF可以比这更好吗?
Am I missing something? Surely EF can work better than this?
推荐答案
您可以将实体映射到返回连接表的视图,因此您的EF模型不知道所有这些技术数据库的东西。
You could map your entities to a view that returns joined tables, so your EF model doesn't know about all this technical DB stuff.
这篇关于实体框架 - 如何管理不同数据库中的表,但在同一台服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文