I've got some LINQ to SQL that sometimes throws a
"Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated."
Is there some way I can turn on logging or at least debug into the datacontext to see what sql is being executed at the time that error is raised?
Update: I should have mentioned I know about the GetChangeSet()
method, I was wondering if there is a property on the DataContext that shows the last SQL that was executed, or a property on the sql exception that shows the SQL.
The odd thing about this error is that in the change sets, there is only one update & the only field that's changing is a datetime field that isn't in the index that causing the error.