ForeignKeyReferenceAlreadyHasValueException…nuff said…

The full title of this post should be “System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the object.” but that would have been a mouthful…I mean ForeignKeyReferenceAlreadyHasValueException kinda just flows out right?  Anyway…

This at first fooled me into thinking it had something to do with the RadGridView control I was using from Telerik UI for WPF…however when I dug a little deeper it had more to do with the Linq to SQL classes that I was using.  They were getting confused about foreign key relationships during the update of their values.  The article I linked seemed to have a good method of explaining what’s going on and how to work around it.  The workaround is instead of setting the value of the foreign key related column…set the object property that gets created for it in the Linq to SQL class.

http://sandeep-tada.blogspot.com/2014/03/systemdatalinqforeignkeyreferencealread.html

Hope this helps someone.  🙂

Advertisements
ForeignKeyReferenceAlreadyHasValueException…nuff said…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s