I have a simple link to three tables. It looks clear enough. Associations are created in DBML. They are not foreign keys in the table definition. What for? It's a long story. Believe me, when I say: I fought in this battle and lost.

When I try to add a new FileType entry using LINQ, it crashes with an error: Unable to insert a NULL value in the column identifier, the FileType table.
_fileType = new FileType() { Id = def.ID, // This is the integer "1" Name = def.Name, FileCategoryId = def.Category.ID, DateLabel = def.DateLabel, FileNamePrefix = def.Prefix, FolderName = def.Folder, CreateInspection = 0 }; try { dc.FileTypes.InsertOnSubmit(_fileType); dc.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); }
But if you notice the code, Id will be installed. I checked the value and it is not equal to zero. This is an integer. What am I missing or is something wrong?
I checked to make sure that the FileCategory entry of the correct identifier exists. Is there anything else I am missing?
source share