I am trying to generate a unique ID for the primary key of a table and I am using DateTime.Now.Ticks
for it. That\'s a requirement for now we can\'t use Ident
Using DateTime.Now.Ticks
as database identity is a very bad idea. Even you resolved the "repeating issue" in your question, your application will probably break in the future, for example, a very common scenario, the application is deployed on multiple servers.
You can either (1) use a database auto-generated, auto-increased id, or (2) use Guid
to fix the issue.
EDIT Under the database performance consideration, auto-increased long
id has a better performance than guid in most circumstances.
EDIT Treat tick
as an unit of time measurement just like year/month/day/hour/minute/second/millisecond/nanosecond. Tick
is between millisecond and nanosecond, 1 millisecond = 100000 ticks.