Print Page | Close Window

Multiple Parent Tables

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3090
Printed Date: 12-Apr-2026 at 11:21am


Topic: Multiple Parent Tables
Posted By: gregweb
Subject: Multiple Parent Tables
Date 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



Replies:
Posted By: gregweb
Date Posted: 12-Nov-2011 at 5:09pm
Never mind, I got this working by changing the data structure a bit.

Greg



Print Page | Close Window