Entity Framework Model from two databases

你说的曾经没有我的故事 提交于 2019-12-13 16:27:24

问题


Is it possible to have an entity model created out of two databases, with all the relationships between tables reflected in the model? How do you do that?

I am referring to ADO.NET Entity Framework version 4.


回答1:


Maybe. It depends on several factors.

If using a modern version of SQL Server, there is a feature called Synonyms, which allows you to "map" a table from one database into another.

Unfortunately, the EF Data designer doesn't recognize or understand Synonyms. There is a way to manually merge two .EDMX files into one, but this is a huge pain.

When using Synonyms, I prefer to use the Code First approach. I use the Entity Framework Power Tools extension to reverse engineer the tables to a code first model, and this works fine with synonyms.

If you want to use .EDMX, then you can try the approach here:

http://rachel53461.wordpress.com/2011/05/22/tricking-ef-to-span-multiple-databases/



来源:https://stackoverflow.com/questions/13790580/entity-framework-model-from-two-databases

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