+1  A: 

it's because you don't have any product with the ID -1, you have to set the default value at NULL and insert null value instead of -1

When you create a foreign key, the sql server check that the inserted foreign key exists in the referenced table, in you case it doesn't exists so the RDMS refuses to insert the row.

remi bourgarel
thank you , How can i assign null to foreignkeys , for example in my Picture Object i have : private int _productId ; and it automatically get 0 value if i don't assign value .
Mostafa
you can set it as nullable :private int? _productIDif you're working with c#http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
remi bourgarel
+1  A: 

why use -1 for undefined? that is what NULL is for! delete the default and allow those rows to have NULL when there is no FK row.

KM
+1  A: 

Why do you have a default value of -1 for your foreign keys? When you insert a new row that doesn't populate one of the foreign keys, then the foreign key will be set to -1 which doesn't match the keyof a row in the foreign table.

I normally just have no default for the foreign key and if there is no link to a row in the foreign table then the foreign key is null. This is legal because you have defined all the foreign keys as nullable

dugbugs