Duplicate GUID problem

  • Thread starter Thread starter Robert Chapman
  • Start date Start date
R

Robert Chapman

I know that this should be impossible, yet it is happening...

I have some c# code that uses a method scoped variable of type Guid. The
code assigns Guid.NewGuid() to the variable. This value is then used as a
primary key in a database table.

I have seen two occasions over the last 6 months where after a certain point
in time the same Guid is always generated by the code.

I have verified that there is nothing static, the code is actually very
simple.

The only interesting fact here is that the code is running under IIS via a
web service. Doing an IISRESET makes the problem go away.

Does anyone have any insight as to how this problem could be??

TIA
Rob
 
I have some c# code that uses a method scoped variable of type Guid. The
code assigns Guid.NewGuid() to the variable. This value is then used as a
primary key in a database table.

TIA
Rob

Don't use GUIDs for primary keys. That's why they invented identity
columns.

Mark
 
Identity columns are no good for:
- replication scenarios
- foreign key relationships in disconnected datasets

Check out any modern product, such as MS CRM, GUIDS are the way to go.
 
Other way around, Mark,

I ONLY use GUIDs as the primary key, if I can help it. I still sometimes
use identity columns, but only as a way to assign a "human friendly" code to
a record whose primary key is still a GUID.

That way, I get much better performance and scalability.
Replication works a darn-site better too.

--- Nick Malik
 
Back
Top