DomainService: Including a Table with a 0..1 relationship


  • Hi there:

    I have two tables: Employees an Images, Each employe can have one image in the Images table, or no image (ImageID == null).

    I want to show each employee along with it's image, but as the image is in other table, then I'm including it in the related query:

    I generated the Domain Service and modified the GetEmployees method to include the Image:

    public IQueryable<Employee> GetEmployees() {
          return this.ObjectContext.Employees.Include("Images"); }

    Then, in the metadata file, I set the [Include] attribute to the Image property of the Employee class:

        public partial class Employee {
            internal sealed class EmployeeMetadata {
                private EmployeeMetadata() {
                // Other properties
                public Image Image {
                //More properties

    When I execute it I get this error: "Load operation failed for query 'GetEmployees'. A specified Include path is not valid"

    Any suggestion?

    Friday, March 23, 2012 4:22 PM


  • Hi Rafael,

    What it means is that in the Include the name of the entity your specified, the main entity does not contain a path to that entity, meaning its enther not related or spelt incorrectly
    Friday, March 23, 2012 9:09 PM