开发者

guid in System.Guid

开发者 https://www.devze.com 2023-03-10 00:26 出处:网络
As per MSDN,开发者_C百科 they describe System.Guid.NewGuid() as .. The chance that the value of the new Guid will be all zeros or equal to any other Guid is very **low**

As per MSDN,开发者_C百科 they describe System.Guid.NewGuid() as ..

The chance that the value of the new Guid will be all zeros or equal to any other Guid is very **low**

Will it be a bad idea to set customerID of Customer table to "uniqueidentifier" and generate the unique id using the System.Guid.NewGuid() ? How can I assure the method will generate only unique IDs ?


Unless you have very good reasons to use Guid as ID, I would recommend against using Guid as key. Guids take a lot of space in a database, and provide no benefit in common scenarios. Plus they do not play well with indexes.

Why don't you set the CustomerID as an integer and set it to auto-generate its value when you insert a new record?

0

精彩评论

暂无评论...
验证码 换一张
取 消