I have a simple three table reference. It looks plain enough. The associations there are created in the DBML. They are not actually foreign keys in the table definition. Why? That’s a long story. Trust me when I say, I’ve fought that battle and lost.

When I attempt to add a new FileType record using LINQ, it crashes with the error: Cannot insert the value NULL into column Id, table FileType.
_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’ll notice the code, Id is being set. I’ve checked the value and it is not null. It is an integer. What am I missing or doing wrong??
I did check to make sure that the FileCategory record of the correct ID exists. Is there anything else I’m missing?
I would give him the props for this, but he left this as a comment, and not an official answer.