Cross Relations Between EF4

I was wondering if EF4 maintains a relationship between databases? For example:

DB1

Author Id Name 

db2

 Posts Id Content db1.Author.Id 

What ideally do I need to do to get this relation in my ef4 model?

Do you have any ideas?

thanks

+7
entity-framework-4
source share
3 answers

I found this entry in Microsoft Connect that answers the question about the support currently provided by EF (in fact, it is not yet supported).

Also found a thread in Social MSDN about this issue.

Other stack overflow links:

  • ADO.Net Entity Framework for Multiple Databases
  • Entity framework 4 and several databases

Thus, the only indicated alternatives are:

+5
source share

If your database supports synonyms, you can trick EF into spanning multiple databases. I wrote how to do it here .

Basically you get an edmx file for each database and a script that combines them into a single edmx file. Synonyms are used to refer to one database from another using the actual table name, so EF does not quit fitting when you try to access database2.table from database1. You still need to manually configure the links between the two databases in the EF model, but after they are installed, they will remain even if you re-run the merge script.

Scripts for setting synonyms and combining edmx files are available at

+4
source share

I recently started a project that uses an entity infrastructure with two databases, one Oracle and one SQL Server. I could not find any information about cross-database or support for multiple databases in the entity infrastructure.

Most of the messages from the MS Entity team are a couple of years old and indicate that the inclusion of two databases in one model is not a feature that will be included in the near future. I would be interested to receive a specific answer on whether it was included in 2010 myself, although I suspect that the answer is no.

Currently, the project bypasses this limitation by having a separate entity model for each database. This solved the problem for most of the scenarios that we encountered at the moment in the project.

In those cases when we needed to simultaneously request data from two databases, we simply created a view in one or other databases. Since we use Oracle and SQL Server, Linked View (SQL) or DBLink (Oracle) will be used in this view.

The drawback of the views in the entity infrastructure is that we had to spend more time than I expected the main working keys to work.

Hope this helps.

+3
source share

All Articles