Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Associate tables from different databases - Entity Framework

I'd like to know how to (if possible) associate tables from different databases using entity framework. I have one edmx for my "xyz" database and another for my "abc" I need to associate them using EF. I know how to fix this using FKs, but that's not what I want, I'd like to be able to do that using the visual editor, not adding, by hand, a FK to my DB.

Here's a pratical example of what I'd like to accomplish:

Table User - database: abc
Table Message - database: xyz

I'd like to associate User to Message and vice-versa.

Could anyone help me?

Thanks!

like image 977
eestein Avatar asked Feb 16 '11 13:02

eestein


1 Answers

You can query them together with Linq-to-Objects, but not with L2S or L2E.

A context is wrapped around 1 Db-connection, you cannot track/update entites from multiple db's.

A possible workaround is to 'link' to one of the Db's from the other. MS-SQL can do this. To the EF it would appear 1 database.

like image 57
Henk Holterman Avatar answered Oct 13 '22 20:10

Henk Holterman