25 Feb, 2013, Bojack wrote in the 1st comment:
Votes: 0
Hey guys, just have a quick question and I cant think of how to go around this. In our database we have a player structure then a squad structure, within the player structure there is a tab for squad which can be nullable. What im having a problem with is trying to remember how to correctly set the players squad to null.

db.player.squad = null;
db.SubmitChanges();

It gives the error: LINQ to SQL ForeignKeyReferenceAlreadyHasValueException error.
Ive searched for solutions but none of them are trying to make it null, all the solutions are switching entities. Anyone have an idea on how to correctly do this? Btw the squad structure, many players can be on the same squad as long as their player squad tab has that id number.
25 Feb, 2013, quixadhal wrote in the 2nd comment:
Votes: 0
Does this "linq" abstraction layer have an API to let you just run real SQL directly? If so, a simple update statement would do it. If not, you'll have to find the documentation and paw through it.
25 Feb, 2013, Tyche wrote in the 3rd comment:
Votes: 0
I know absolutely nothing about LINQ, however I do know a fair bit about SQL Server.
The column has to be defined as able to be NULL, as in…
column INT NULL FOREIGN KEY REFERENCES othertable(column)
If it is maybe this LINQ thing is getting in your way.
0.0/3