jeudi 14 janvier 2016

Required attribute NULL in database

I've been trying to add additional attributes to the Identity model, but I want them to be obligatory. But, setting them as Required are causing 2 problems

  1. Attribute is not being set as Not Null in database
  2. Application crashes instead of returning beautiful errors to be displayed in the register window

    public class User : IdentityUser
    {
        [Required]
        public string Name { get; set; }
    
        [Required]
        public virtual Brand Brand { get; set; }
    
        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User> manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
            // Add custom user claims here
            return userIdentity;
        }
     }
    
    

Could somebody help me? Thanks!

Aucun commentaire:

Enregistrer un commentaire