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

前端 未结 3 1969
滥情空心
滥情空心 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 17:12

    The intent was to allow both arbitrary id types (i.e. int, guid, string), but also avoid having serialization/casting issues for the id property.

    So you can define your keys however you like and just implement the interface method

    public class MyUser : IUser {
      public int Id { get; set; }
      string IUser.Id { get { return Id.ToString(); } }
    }
    

提交回复
热议问题