LINQ to SQL NullReferenceException on SubmitChanges
- π
- π 176 words
- π 1 minute
- π¦ .NET
- π·οΈ LINQ
- π¬ 5 responses
Iβve been busy working on some LINQ to SQL (formerly DLINQ) apps that have been going well bar a NullReferenceException thrown at me from deep in the bowels of LINQ and itβs change tracker. A cursory glance in debug showed none of the properties that represent columns were nullβ¦
The null was actually a collection property that represented a one-to-many relationship that was automatically created using the foreign key constraints in the database. Normally this is set to an empty EntitySet however I was failing to call the default constructor from my new useful constructor.