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.
精彩评论