5. November 2010 01:58
/
jstawski
/
Comments (3)
Tonight I ran into a weird problem that I haven’t seen before. I was getting an entity back from a query, changing some values, and calling the DataContext.SubmitChanges() and the database was not being updated. The code ran fine without any exceptions. Weird! I decided to fire up SQL Server Profiler and see what queries were being executed and to my surprise Linq To Sql (L2S) was not executing anything. After 5 minutes of thinking why that would be the case the light bulb turned on! I didn’t have a Primary Key set on the table. Why I didn’t have one it’s not important other than this table didn’t really need it as far as SQL Server is concerned. It turns out that L2S does need one in order to generate updates.
Happy Programming!
1fd42e87-25d3-446c-b545-1e89a8fe8451|13|2.8|27604f05-86ad-47ef-9e05-950bb762570c