none
Multiple Foreign keys to single table RRS feed

  • Question

  • I think I know the answer to this, but just in case.

     

    I have a table Customer.  A customer can have two Address:  ShippingAddress and BillingAddress.   There are two foreign keys between Customer and Address.  FK_Customer_ShippingAddress and FK_Customer_BillingAddress.

     

    When LINQToSQL generates the DBML, I get Address1 and Address2.  I know I can go into the DBML and change the name, but obviously, everytime I alter the DBML, I lose the names, and have to remember to go in and reset them.

     

    Is there any way to set the properties of the FK on the database so that LINQToSQL uses a relationship name specified there each time instead of coming up with it's own name?  Alternatively, can I add a relationship in the partial classes which would override the FK relationship generated by the dbml without removing the relationship from the database or removing it manually after every recreate?

     

    Thanks

    Monday, July 14, 2008 5:28 PM

Answers