Is it possible to set the value of an auto-increment field? If a record is deleted with primary key 5, but the current auto-increment count is 10, is there any way to re-insert that record with its primary key still remaining at 5 (instead of 11)? I am trying to do this with Entity Framework 4.1 in C#.
Share
Although there were several good suggestions here, I came to realize several things while working with the solution to this question. The disclosure that the database was a MySQL perhaps would have helped here but I did not at the time realize the difference would be so substantial. In fact, in MySql there is no lock against inserting into an auto-increment primary key. As a result, this code works to insert a record with a primary key less than the current value of the auto-increment index:
Properly inserting a record with the index of 5, even if the current auto-increment count is at 11.