开发者

Entity Framework 4, can I have 2 tables from different db servers in the same model?

开发者 https://www.devze.com 2023-02-16 13:42 出处:网络
With Ent开发者_如何学JAVAity Framework 4, can I have 2 tables from different db servers in the same model?

With Ent开发者_如何学JAVAity Framework 4, can I have 2 tables from different db servers in the same model? I have table X from SQL Server A and Table Y from Server B. Is it possible to have different connection string per table under one model or do I need to have different dbml files?


No you can't. Whole EDMX file have single connection string. Moreover EF don't allow fully qualified names of tables. Defining table TableA a from linked server MyServer.MyDatabase.dbo will probably in SQL query result in something like [MyServer.MyDatabase.dbo].[TableA] and it will throw exception.

If you want support tables from two servers in a single model, try to link your second server to the first server and create a view for each table from the second server in your current database on the first server.


IIRC you might be able to fully qualify the table name in the DBML if they are linked servers. I don't have anything to test on, I know you can do it in Linq2Sql on Different databases on the same server.

0

精彩评论

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