New Posts New Posts RSS Feed: Multiple Parent Tables
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Multiple Parent Tables

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Multiple Parent Tables
    Posted: 11-Nov-2011 at 8:06pm
I have two tables: Contacts and Addresses.

The Addresses table has a field called EntityId. There is a foreign key relation to Contacts. This works just fine, and the navigation properties work as expected between Contacts and Addresses.

Now I add a new table in called Companies. I add a second Foreign key relation to Addresses, so it can relate back to either a Contact or a company.

As soon as I do this, the navagation between Contacts and Addresses breaks. The error that is thrown is System.Data.SqlClient.SqlException: Invalid column name 'Company_Id'

It appears what is happening is that it is trying to populate the Addresses->Companies properties and of course fails as Companies isn't available just then.

What I am tring to achieve is that I can relate an address to either a Contact or a Company.

Greg
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2011 at 5:09pm
Never mind, I got this working by changing the data structure a bit.

Greg
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down