7

So when I run the following, the role is inserted but the ID column is auto generated. How do I stop this from happening when using Linqpad?

Roles.InsertOnSubmit(new Role(){ID = 26, Name = "TheRole", Created = DateTime.Now, Updated = DateTime.Now});    
SubmitChanges(); 
LivingOnACloud
  • 1,151
  • 1
  • 11
  • 20

1 Answers1

2

The ID column is set to AUTO INCREMENT in database, you can't override that from LINQ, you have to modify your database table schema to remove AUTO INCREMENT from table.

You can also enable IDENTITY_INSERT if you are using ADO.Net, see this question for related SQL details.

Community
  • 1
  • 1
Habib
  • 219,104
  • 29
  • 407
  • 436