Why do the ASP.NET Identity interfaces use strings for primary and foreign keys?

前端 未结 3 1960
滥情空心
滥情空心 2020-12-04 16:40

I\'m looking at the interfaces on the new ASP.NET Identity classes and the database it creates using Entity Framework Code First. I\'m using the Visual Studio 2013 RC.

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 16:54

    Adding to what Hao said:

    1. The Identity runtime prefers strings for the user ID because we don’t want to be in the business of figuring out proper serialization of the user IDs (we use strings for claims as well for the same reason), e.g. all (or most) of the Identity interfaces refer to user ID as a string.
    2. People that customize the persistence layer, e.g. the entity types, can choose whatever type they want for keys, but then they own providing us with a string representation of the keys.
    3. By default we use the string representation of GUIDs for each new user, but that is just because it provides a very easy way for us to automatically generate unique IDs.

提交回复
热议问题