I have a Model called Sammanhang
[Key]
public int SammanhangsID { get; set; }
public string Namn { get; set; }
And I want to include the id of the users as a foreign key so that i can get a dropdown-list of all the users in the database.
I attepmted doing something like this
public class Sammanhang
{
[Key]
public int SammanhangsID { get; set; }
public string Namn { get; set; }
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual ApplicationUser ApplicationUser { get; set; }
}
and inside IdentityModels
public class ApplicationUser : IdentityUser
{
public virtual Sammanhang Sammanhang { get; set; }
}
But without no success, Is there anyway to achieve a user dropdownlist?