I have a simple desktop application that is using SQL Server Compact (3.5 and about to be upgraded to 4.0).
In my main customers table, in addition to the ID
column - which is the PK and is auto incremented, I need to hold a Number
column that starts in some number (20000) and is unique.
The option of computing the next number by the existing highest row is not a good one - if other client is adding a customer between my first selection to my inserting - I'll have a problem.
As pointed in many places, SqlCE auto incremented column should be Identity
column, and in each table could be only one Identity
column.
Is there other practice you know to solve this problem?
BTW - I am using Linq to ADO .net.
Edit:
Just found this link and discovered that I can use even the Identity option with linq to Entities framework: http://erikej.blogspot.com/2010/04/solutions-to-server-generated-keys-and.html