I am facing a problem where my entity framework keeps behaving weirdly when I try to instantiate any class. I am trying to use the default usermanager behaviour
You don't have any foreign key to link AssociatedUser
. Try adding a property to link Notification
to ApplicationUser
using foreign key. Like
public class Notification
{
//rest of properties
//change int to whatever type your primary key is in
//ApplicationUser class. I have Guid for example.
public int ApplicationUser AssociatedUserId {get;set;}
}
Then try modifying configuration like this:
modelBuilder.Entity<Notification>()
.HasRequired(c => c.AssociatedUser)
.WithMany(c => c.Notifications)
.HasForeignKey(n=>n.AssociatedUserId);