开发者

Entity Framework 4 and Synonyms

开发者 https://www.devze.com 2023-01-21 17:50 出处:网络
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 re

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 curiou开发者_运维百科s 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消