I have a service class and I have the User responsible for the service, which is a user of IdentityUser
.
Remembering that I changed the String Identity Id to "Int", just that.
I can usually register, however, when I edit, it lists the users, but does not set the user who is already registered in the service.
Entity:
[Table("Atendimentos")]
public class Atendimento
{
[Key]
public int AtendimentoId { get; set; }
public int UsuarioId { get; set; }
[Display(Name = "Responsável pelo atendimento")]
public virtual Usuario Usuario { get; set; }
}
Controller:
ViewBag.UsuarioId = new SelectList(db.Users.Select(x => new { UsuarioId = x.Id, Nome = x.Nome + " " + x.Sobrenome }), "UsuarioId", "Nome");
View:
@Html.DropDownList("UsuarioId", null, htmlAttributes: new { @class = "form-control" })
I have tried to put the property "UserId" to "Id" pens, because Identity uses only "Id", even though it did not work.