0

Possible Duplicate:
EF4 cross database relationships

Is it possible to have 3 databases:

  • Shared (with country, currency, etc tables)
  • Website1 (user, product, order, etc.. tables)
  • Website2 (user, product, order, etc.. tables)

And using (for example) Entity Framework with FK like:

  • Website2_Product_Shared_Country
  • Website1_Product_Shared_Country

Is it possible to have this kind of relationships on EF?

Community
  • 1
  • 1
Bart Calixto
  • 19,210
  • 11
  • 78
  • 114

1 Answers1

0

In general it should be possible to have those 3 databases in the same project.

But I see some troubles rising by the possible differences in the implementations of the EF data provider for the various database systems. All databases behave slighty different and it might happen that some code that works with one DB might produce errors with the next one.

The general idea of the Entity Framework should abstract your code from troubles like this, but reality shows that you still might encounter some quirks.

To your second question, foreign keys over different databases look too dangerous to me to even think about it. Just think aout a possible faile of one database that then needs to be reset.

Then what happens to everthing in the other two databases? How will you enfore data integrity for all changes that happend between failure and restore...?

This would without a doubt put a lot of pressure on your foreign keys and who-knows-what-else...

Jens H
  • 4,590
  • 2
  • 25
  • 35
  • so the recommendation is to duplicate the 'shared database' tables into the website1,website2 and update both ways or use triggers that updates both ? – Bart Calixto Dec 26 '11 at 23:58
  • 1
    Would it be possibe for you to use a web service (or else) as the only process that is allowed to access the DB and provides the data (or updates it) and that is called by both web sites? – Jens H Dec 27 '11 at 00:11
  • mmmm and referencing everything by id ... you know what? sounds great ... I will prototype something to try. – Bart Calixto Dec 27 '11 at 00:23