views:

259

answers:

1

Hey,

I have a Website table that has a foreign key to a Client table. A Website isn't always going to have an associated Client but when I save a Website without specifying a client then it errors out, as Website.ClientID is an int32 (not nullable) and is set to 0. I tried changing the relationship in my EF diagram to be a * next to Website and a 0..1 next to Client but then it gives an error saying that it can't do 0..1 for ClientID because it's not nullable. I then changed Website.ClientID to be nullable, however now it gives this error:

TothSolutions.msl(69,10) : error 3031: Problem in mapping fragments starting at line 69:Non-nullable column Website.ClientID in table Website is mapped to a nullable entity property.

How do I set up a foreign key relationship where the dependant object is nullable? They sure don't make this stuff easy in EF, I miss L2S...

Thanks, Justin

A: 

I forgot to take the not null off the column in the database, duh...

Justin