title: Modelstate is not valid because the password im creating that is invalid
body: <p>So I have been trying to debug why my modelstate is not valid, and when I go through debugging mode, I found out that the password field that I am trying to create is invalid and sometimes it becomes valid when I type in 'password' but most of the time when I randomly type in a password its invalid</p>
  <p>I can to to debug and found out it was the password field as shown below
  <a href="https://i.stack.imgur.com/YsaPT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YsaPT.png" alt="enter image description here" /></a></p>
  <p>So I went onto my models to add some validation and it still wasn't able to add most of the times,</p>
  <p>this is my appUser model where the password is a byte[],</p>
  <pre><code>    public int Id { get; set; }
  
      [Required(ErrorMessage =&quot;Name is required&quot;)]
      public string Name { get; set; }
  
      [Required(ErrorMessage = &quot;Password is required&quot;)]
      [DataType(DataType.Password, ErrorMessage =&quot;password is not valid, has to be 8 characters long&quot;)]
      public byte[] Password { get; set; }
  
      [Required(ErrorMessage = &quot;Role is required&quot;)]
      public int RoleId { get; set; }
  
      [Required(ErrorMessage = &quot;Email is required&quot;)]
      [EmailAddress(ErrorMessage =&quot;Invalid Email&quot;)]
      public string Email { get; set; }
  
      [Required(ErrorMessage = &quot;Job title is required&quot;)]
      public string JobTitle { get; set; }
  
      [Required(ErrorMessage = &quot;Department is required&quot;)]
      public string Department { get; set; }
  
      public virtual Roles Role { get; set; }
      public virtual ICollection&lt;Booking&gt; Booking { get; set; }
  }
  </code></pre>
  <p>so what can I do to actually get rid of this bug?</p>
  <p>Now I actually get this error and when I debug it said that the line int res == -1 when it should be 1.</p>
  <p>How can I fix this?</p>
  <p><a href="https://i.stack.imgur.com/VEEke.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VEEke.png" alt="enter image description here" /></a></p>