App Details: C#, ASP.NET MVC, SQL Server 2008 ( Same version & SP level), Linq-To-SQL ORM
I\'m trying to diagnose an exception I\'m receiving:
This is a well-known bug in LINQ to SQL.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351358
There is a hotfix for the issue.
http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=963657&kbln=en-us
If that key exists in a defined relationship and the object is already created then the LINQ-provided relationship path (obj.Foo = new Foo { ... }
) must be used. (I would use the provided relationships even for new objects). Failure to do so will result -- speaking from experience -- in "random" errors like that.
Another issue that can cause that (or a very similar error) is reversed relationship columns, for compound relationships. However, if the generated code is the same and the DB is the same (for real, on both accounts) then I suspect the first reason is the culprit.
Happy SQL-to-LINQ pothole jumping.