Why is ASP.NET Identity 2.0 using a GUID/string as user id?

后端 未结 5 1842
攒了一身酷
攒了一身酷 2020-12-14 01:07

As the title says, I wonder, why ASP.NET Identity 2.0 uses a string with a GUID as primary clustered key for the user table. Does this have any advantages to an integer id?

5条回答
  •  眼角桃花
    2020-12-14 01:57

    I assume that by "to an id" you mean a sequential integral ID, as a UUID is after all an ID.

    If absolutely nobody using Identity 2.0, or a future version, ever wanted to merge together, or combine more than one store, or ever import users and/or rôles, then a numerical ID would work.

    If just a few people do, or even might, then a UUID makes a lot more sense.

    There's an argument to be made for using a natural key, such as a username, with the pros and cons of that being well-explored generally. IIRC, they did indeed do this the first time.

    In all, a UUID seems an obvious choice.

提交回复
热议问题