Reputation: 33880
Is it possible to have an entity model created out of two databases, with all the relationships between tables reflected in the model? How do you do that?
I am referring to ADO.NET Entity Framework version 4.
Upvotes: 2
Views: 1426
Reputation: 93474
Maybe. It depends on several factors.
If using a modern version of SQL Server, there is a feature called Synonyms, which allows you to "map" a table from one database into another.
Unfortunately, the EF Data designer doesn't recognize or understand Synonyms. There is a way to manually merge two .EDMX files into one, but this is a huge pain.
When using Synonyms, I prefer to use the Code First approach. I use the Entity Framework Power Tools extension to reverse engineer the tables to a code first model, and this works fine with synonyms.
If you want to use .EDMX, then you can try the approach here:
http://rachel53461.wordpress.com/2011/05/22/tricking-ef-to-span-multiple-databases/
Upvotes: 5