Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why in Asp.Net Identity 2.0 PhoneNumber is [nvarchar](max)

I am using Asp.Net Identity 2.0 in my MVC 5 project.

Why is column PhoneNumber using [nvarchar](max) in SQL Server database table [dbo].[AspNetUsers]?

Can I change this to [nvarchar](64), for example?

like image 488
sDima Avatar asked Sep 19 '14 11:09

sDima


1 Answers

I created a class ApplicationUser : IdentityUser in which I override property PhoneNumber with attribute [MaxLength(64)].

public class ApplicationUser : IdentityUser
{
    [MaxLength(64)]
    public override string PhoneNumber { get; set; }

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        return userIdentity;
    }
}
like image 81
sDima Avatar answered Oct 01 '22 00:10

sDima