How do i update a foreign key column back to null?
On insert or update i use this:
getCategory = _db.Categories.Find(id);
Events.Categories = getCategory; //add foreign key
But if the category is 0 (not selected) i want to update the relationship Category_ID back to null.
Try to do it like that:
Events.Categories = null; //add foreign key
But it doesn't seems to work
Please advise
Thanks
How to update foreign key back to NULL?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sandeep Singh ShekhawatRank #147 · 15.6K pointsPosted Oct 21, 2013, 2:03 AM EDT
Thanks,
Sandeep
nave21 pointsPosted Oct 21, 2013, 2:43 AM EDT
So is there a way to delete the relationship?
Please advise
Thanks