If your SQL Server automatically provides default values for certain columns, you may be scratching your head wondering why Linq to SQL throws errors when you don't provide values for those columns whenever you insert rows.

It seems like a simple fix and luckily it is, albeit a bit buried in forum threads. Contrary to what you might think, if you want to change that column in your code (the majority of the columns you probably have), you cannot set Auto Generated Value to true.

As far as I understand, Auto Generated Value refers to a calculated column and so Linq to SQL will prevent you from editing it or changing it.

The key is to set Auto-Sync to either OnInsert, OnUpdate, or Always.

If you have a column that has a default value which you do not want the program to modify:


(Note: I think only setting Read Only to True should be fine instead of also changing Auto Generated Value but I haven't tested it.)

If you have a column that needs a default value on Insert only and you update it throughout your application:


You can play with Auto-Sync to get what you want, but that's how Linq to SQL takes care of Default Values.

In code-behind, the three attributes look like this:

public DateTime Created