Linq to Sql- AutoID not working
July 31, 2009
Using Linq to Sql Auto IDs do not work by default.
Lets say you have a table “Property” with a primary key of “PropertyId”. In the table definition it is set as a unqueidentifier and by default it is assigned a NewID().
Now go to your Linq to Sql and create your dbml, drag your Property table into it.
In order to have the PropertyId generated using the Default Value go to the properties of the PropertyId field and set Auto Generate Value to True and Auto-Sync to OnInsert.

I am sure many already know this, but I hope it can help save some time for others.
-
Categories
- asp.net (11)
- Blog (1)
- Business (5)
- Conferences (1)
- Errors (3)
- Portfolio (2)
- Reviews (2)
- SQL Server (3)
- Tips (1)
- Uncategorized (1)
- Web Development (13)
-
Archives