none
RE: Non-projection includes error on foreign key

    Question

  • Hey!

    Today I ran into a very weird issue with WCF-Services. I have two inheritance structures in my entity-domain:

    1) Doctor and Assistant, which both inherit from Staff, which interits from User
    2) PlanningAppointment and PatientAppointment, which both inherit from Appointment

    In Staff, I want a:

    [Include]
    public ICollection<Appointment> Appointments { getset; }

    and in Appointment I want:

    [Include]
    public
     Staff Staff { getset; }
    public int StaffId { getset; }

    I have tons of other classes that do that. But in this particular instance, WCF RIA Services start to cry (btw, I use the latest Ria.EntityFramework NuGet package). The compiler says:

    Error 1 Invalid Include specification for member 'Staff.Appointments'. Non-projection includes can only be specified on members with the AssociationAttribute applied. [...]
    Error 2 Invalid Include specification for member 'Appointment.Staff'. Non-projection includes can only be specified on members with the AssociationAttribute applied. [...]

    If I remove the [Include] on the ICollection, the error is gone (but of course, on the SL side, I don't have a Staff.Appointments attribute).

    I already tried to put an [Association]-attribute on there. This fixes this particular error, but this sets a whole cascade of errors in motion where I end up putting an [Association]-attribute on every foreign-key and a [Key]-attribute on every entity - error by error (fixing one triggers the next, ...). When I'm done with that, the generated code in Silverlight wants to compare the Id to an EntityCollection in the filter-methods -> fail.

    Where does this suddenly come from? Why doesn't it work on those two classes?

     

    Thursday, May 03, 2012 8:15 AM

Answers