Getting a serial number from shared table I have a table that keeps track of a global serial number shared between several tables. This is not the PK or unique id for each table. It is like a case identifier. Every time users create a new entity we need to give them a unique serial number from this row. My worries is what happens if 2 users hit the method for incrementing this counter at the exact same time. Would this solution be enough?

Also this code would be run from 2 servers using the same database.

public string GetIdentifier()
{
    int retries = 0;
    bool success = false;

    string newId;

    do
    {
        try
        {
            var tracker = Trackers.Find(1);
            newId = tracker.Increment();
            SaveChanges();
            success = true;

        }
        catch (DbUpdateConcurrencyException)
        {
            Thread.Sleep(500);
            if (++retries == 5)
                throw;
        }
        catch (Exception)
        {
            //do some logging
            throw;
        }

    } while (!success);

    return newId;
}
You propably won't ever get the effect that 2 people create the same unique identifier at the same time. Still, it could possibly happen, most databases will handle this. If you create your db with unique values only in your table, it will automatically give you an error when 2 values are identic.