The property cannot be configured as navigation property

c# entity-framework

Question

I'm attempting to implement the domain model My model.

This mvc application uses the entity framework. The model's code appears as follows:

public class Login
{
    [Key]
    public int LoginID { get; set; }

    public virtual Therapist Therapist { get; set; }

    public virtual Patient Patient { get; set; }
}

public class Patient
{
    [Key]
    [ForeignKey("Login")]
    [Display(Name = "No.")]
    public int PatientId { get; set; }

    [ForeignKey("Therapist")]
    public int TherapistId { get; set; }

    [ForeignKey("Therapist")]
    public int TherapistId{ get; set; }

    public virtual Therapist Therapist { get; set; }

    public virtual Login Login { get; set; }
}

public class Therapist
{
    [Key]
    [ForeignKey("Login")]
    [Display(Name = "No.")]
    public int TherapistId { get; set; }

    [ForeignKey("Login")]
    public int LoginId { get; set; }

    public virtual Login Login { get; set; }

    public virtual ICollection<Patient> Patients { get; set; }
}

I precisely follow the instructions in the tutorials and Stack Overflow questions, but no matter what I do, I always see the same issue when attempting to run the controller:

Unable to retrieve metadata for 'Patient'. The property "TherapistId" cannot be configured as navigation property. The property must be a valid entity type and the property should have non-abstract getter and setter. For collection properties the type must implement ICollection where T is a valid entity type

I'm not sure what's wrong withTherapistId So perhaps the model's entire premise is absurd?

1
5
8/31/2018 6:06:56 AM

Popular Answer

ZZZ_tmp
19
6/6/2015 12:02:17 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow