Note: for this question, I've simplified the models a bit.
Im working on an ASP.NET Core MVC application (with Entity Framework Core). I have three models. I have an ApplicationUser (that extends from IdentityUser), I have an Activity model and I have a 'SignUp' model that has a foreign key to an activity and a foreign key to ApplicationUser. At least, that's the idea. The thing is, Entity Framework recognices the Activity FK as a FK, but not the applicationuser. That just becomes another int in the database without any FK constraints.
I've tried a lot of things that I found on the internet, but I can't get it to work. This is what I currently have (shortened for clarity):
Activity:
public class Activity
{
public Activity()
{
SignUps = new HashSet<SignUp>();
}
public int ActivityID { get; set; }
[Required]
[StringLength(50)]
[Display(Name = "Naam")]
public string Name { get; set; }
public virtual ICollection<SignUp> SignUps { get; set; }
}
ApplicationUser:
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
{
Activities = new HashSet<Activity>();
}
[Required]
[Display(Name = "Voornaam")]
public string FirstName { get; set; }
[Required]
[Display(Name = "Achternaam")]
public string LastName { get; set; }
public virtual ICollection<Activity> Activities { get; set; }
}
SignUp:
public class SignUp
{
public int SignUpID { get; set; }
[Required]
public int ActivityID { get; set; }
[ForeignKey("ApplicationUser")]
public int ApplicationUserID { get; set; }
[Required]
public string Status { get; set; }
}
Note: I first did not have the [ForeignKey] attribute (like with activity), but it's there because I was trying to get it working.
As I said above, the Activity FK in SignUp works fine, the Applicationuser FK doesn't. Entity Framework just generates an int in the database without any FK constraints and when scaffolding CRUD pages, it's also not recognized as an FK.
I'm quite new to ASP.net MVC and EF and I have the feeling I'm overlooking something very simple. Facepalm moment incoming?
Thanks!