IdentityUser的UserName属性的默认DataAnnotations是什么?

时间:2015-07-06 21:48:05

标签: asp.net-identity

DataAnnotations IdentityUser媒体资源的默认UserName是多少?我无法找到它们。

我想知道,因为我想覆盖该属性以向该属性添加更多DataAnnotations,但是当重写时,所有旧的DataAnnotations都将丢失。我需要知道他们将它们添加到被覆盖的属性中。

1 个答案:

答案 0 :(得分:1)

默认框架实现中Username上没有数据注释:

public class IdentityUser<TKey, TLogin, TRole, TClaim> : IUser<TKey>
    where TLogin : IdentityUserLogin<TKey>
    where TRole : IdentityUserRole<TKey>
    where TClaim : IdentityUserClaim<TKey>
{
    /// <summary>
    ///     Constructor
    /// </summary>
    public IdentityUser()
    {
        Claims = new List<TClaim>();
        Roles = new List<TRole>();
        Logins = new List<TLogin>();
    }

    /// SNIP


    /// <summary>
    ///     User ID (Primary Key)
    /// </summary>
    public virtual TKey Id { get; set; }

    /// <summary>
    ///     User name
    /// </summary>
    public virtual string UserName { get; set; }
}

以下是源代码:https://aspnetidentity.codeplex.com/SourceControl/latest#src/Microsoft.AspNet.Identity.EntityFramework/IdentityUser.cs