Entity Framework - how to manage tables in different databases but on the same server?

◇◆丶佛笑我妖孽 提交于 2020-01-01 16:25:08

问题


I am using SQL Server 2008.

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.

Am I missing something? Surely EF can work better than this?


回答1:


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.




回答2:


I don't think it's properly supported, but this guy has managed to get it to work.

Basically, she set up Synonyms for the databases, and hacked the edmx file.



来源:https://stackoverflow.com/questions/11544516/entity-framework-how-to-manage-tables-in-different-databases-but-on-the-same-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!