irl_irl
irl_irl

Reputation: 3975

How can I add a foreign key from a table in another database connection?

I have set up a ASP.net MVC application which uses the default forms authentication. It uses the ASPNETDB.mdf like shown here: alt text

I then set up another database connection which is similar to the NerdDinner.mdf file above.

I have a post that belongs to a user. It has a UserId value which needs to be a foreign key to the information in ASPNETDB.mdf. When I go to add a foreign key, I can only see information with regards to the table I made. How do I go about doing this?

Upvotes: 1

Views: 1585

Answers (1)

Oded
Oded

Reputation: 498972

Even if it were possible (which is isn't), this would be a bad idea - chaining databases in this manner would only cause problems down the line.

  • If one database is down, so is the other.
  • If the network between database servers (assuming different servers), both are down.

From MSDN:

A FOREIGN KEY constraint can reference columns in tables in the same database or within the same table.

(emphasis mine)

Upvotes: 3

Related Questions