I have a classes structure something like that:
public class Customer{
public AgreementDetails Agreement { get; set; }
}
[ComplexType]
public class AgreementDetails{
public int SalesPersonId { get; set; }
[ForeignKey("SalesPersonId")]
[NotMapped]
public virtual SalesPerson Sales { get; set; }
}
public class SalesPerson
{
...
}
When I'm displaying the list of customers, i'm calling Sales property to disaply sales person details but property is null, usually for navigating properties this can be avoid using .Include method but it doesn't work in my case, so the query is
List<Customer> res = db.Customers.Include(c=>c.Agreement.Sales).ToList();
The exception is:
A specified Include path is not valid. The EntityType 'CodeFirstNamespace.Customer' does not declare a navigation property with the name 'Agreement'.