How can I limit the UserName field in the AspNetUsers table?
Nothing:
public class ApplicationUser : IdentityUser { [Required, MaxLength(15)] public string UserName { get; set; } }
or that:
modelBuilder.Entity<ApplicationUser>().Property(x => x.UserName).HasMaxLength(15);
work.
I need this because setting Index to nvarchar(max) gives me this msg error:
The column "UserName" in the table "dbo.AspNetUsers" has a type that is not valid for use as a key column in the index.
To be detailed, I tried to set the indexes as follows:
public override void Up() { CreateIndex("dbo.AspNetUsers", "UserName", true, "IX_UserName"); } public override void Down() { DropIndex("dbo.AspNetUsers", "IX_UserName"); }
entity-framework username asp.net-identity ef-code-first entity-framework-6
Yustme
source share