Entity Framework 4 and Synonyms

↘锁芯ラ 提交于 2019-12-12 12:35:06

问题


If, in Database A, there exists a table named "MyTable" that actually comes from a synonym pointing to another database (B), can I create this table as an entity in an Entity Framework model that represents database A, since it actually resides in a different database?

I'm curious if the situation with EF 4 has improved since this: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/fff1067a-650d-4b47-a4e8-79eedebe5c11/

Thanks.


回答1:


The answer is no, it is not supported yet; you can track the status of the issue here: http://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions/suggestions/1052345-support-for-multiple-databases?ref=title




回答2:


Get rid of your synonym and use a view instead which looks like

CREATE view [dbo].[MyTable] as
  select * from B.dbo.MyTable

You can then bring this view into Entity Framework and treat it as a table.



来源:https://stackoverflow.com/questions/4018202/entity-framework-4-and-synonyms

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