none
LINQ2SQL Design - Associations not created for Nullable Foreign Key RRS feed

  • Question

  • I have a database record, ResourceRequest which has three nullable foreign key. There's a business rule that at least one foreign key must be set, but this is dealt with in business logic.

     

    My problem is that, unexpectedly, if the foreign keys are nullable then the linq designer doesn't drop the associations in for me. If I make the foreign keys non nullable, everything is fine.

     

    I guess could write code to deal with this but this surprised me. If I manually try to add the association I am told that I can't because the property types are not the same, presumably because one is nullable type and the other is not.

     

    I wouldn't imagine I'm the first guy to come across this.

     

    Any thoughts from you guys?

     

    Thanks

    Thursday, April 3, 2008 2:22 PM

Answers