EF 4.0 Guid or Int as A primary Key
Posted
by
bigb
on Stack Overflow
See other posts from Stack Overflow
or by bigb
Published on 2011-01-04T13:01:10Z
Indexed on
2011/01/04
13:53 UTC
Read the original article
Hit count: 190
sql-server-2008
|entity-framework-4
I am Implementing custom ASPNetMembership using EF 4.0
Is there any reason why i should use Guid as a primary key in User tables?
As far as i know Int as a PK on SQL Server more performanced than strings.
And Int is easier to iterate. Also, for security purpose if i need to pass this it id somewhere in url i may encrypt it somehow and pass it like a strings with no probs.
But if i want to use auto generated Guid on SQL Server side using EF 4.0 i need to do this trick http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/
I can't see any cases why i should use Guid as PK, may be only one if system going to have millions ans millions users, but also, theoretically, Guid could be duplicated sometime isn't so?
Anyway Int32 size is 2,147.483.647 it is pretty much even for very-very big system, but if this number is still not enough I may go with Int64, in that cases I may have 9,223.372.036.854.775.807 rows. Pretty much huh?
From another hand, M$ using Guids as PK in their ASPNetMembership implementation. [aspnetdb].[aspnet_Users] -> PK UserId Type uniqueidentifier, should be some reasons/explanation why the did it?!
May be some one has any ideas/experience about that?
© Stack Overflow or respective owner