2
I have the following properties, however when I will validate via Modelstate.Isvalid returns that the description of the user group to be informed that it is User too, but the problem is that I am asking for the database itself to generate the key. How do I not present these inconsistencies?
Groupuser is being filled with a Dropdownlist.
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UsuarioId { get; set; }
[Required(ErrorMessage = "Nome do usuário deve ser informado")]
public string UsuarioDeAcesso { get; set; }
[Required(ErrorMessage = "Senha do usuário deve ser informada")]
public string SenhaDeAcesso { get; set; }
[Required(ErrorMessage = "Grupo deve ser selecionado")]
public int GrupoDeUsuarioId { get; set; }
[Required(ErrorMessage = "Grupo deve ser selecionado")]
public GrupoDeUsuario GrupoDeUsuario { get; set; }
One way I found was to use this.ModelState.Remove("User"); but I think for this case is not the most appropriate.
– DouglasMendes