Search code examples
silverlightentity-framework-4.1wcf-ria-services

WCF RIA SERVICES and EF 4.1


Do I have to explicitly add the [Include] attribute for any entities that has ICollection property so that result LoadOperation callback will populate my entity with its collection?

Querying the data from the Service is fine, but when being passed to the LoadOperation it doesn't add the collection of a certain entity. Does it have something to do with serialization/deserialization from the service message?

If yes, what is the reason why? I have used EF with DbContext.Includes in WPF but I did not have any issues with my T4 template generated items when I wanted to query my entity's collection.


Solution

  • The [Include] attribute is required to advise the WCF marshaller to serialize related entities. Specifically, MSDN advises

    this attribute specifies that the association should be part of any code-generated client entities, and that any related entities should be included when serializing results to the client.

    You will still need to use the query.Include() on your DbContext to retrieve the related data from the database.