I followed the example here
https://docs.microsoft.com/en-us/ef/core/querying/related-data#lazy-loading
And my two classes look like this
public class RefMedSchool
{
public int Id { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public virtual ICollection<ApplicationUser> ApplicationUser { get; set; }
}
public class ApplicationUser : IdentityUser
{
public string UserFirstName { get; set; }
public string UserLastName { get; set; }
public bool MustChangePassword { get; set; }
public int? MedicalSpecialtyId { get; set; }
[ForeignKey("RefMedicalSpecialtyForeignKey")]
public RefMedicalSpecialty RefMedicalSpecialty { get; set; }
public int RefMedSchoolId { get; set; }
public virtual RefMedSchool RefMedSchool { get; set; }
public UserProfileData UserProfileData { get; set; }
public ICollection<UserFeedback> UserFeedbacks { get; set; }
public ICollection<UserAction> UserActions { get; set; }
public ICollection<UserProgram> UserPrograms { get; set; }
}
But when the database tries to be created I get the error below. Whats wrong ? The properties are virtual as needed.
System.InvalidOperationException: 'Navigation property 'RefMedicalSpecialty' on entity type 'ApplicationUser' is not virtual. UseLazyLoadingProxies requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or protected constructor.'