I am getting an error when using .Include – A specified Include path is not valid. The EntityType 'myProject.DAL.Paint' does not declare a navigation property with the name 'Color'.
DAL
public DBSet<Palete> Paletes {get; set; }
public DbSet<Paint> Paints { get; set; }
(note: modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();)
Model
public class Palete
{
public virtual Paint Paint { get; set; }
}
public class Paint
{
public string Color { get; set; }
}
query = query.Include(pal => pal.Paint.Color);
How can I fix this error?
Coloris a string property – you shouldn’t need anIncludehere sinceColordoesn’t refer to a separate entity.Given the update doing just
should work – if you are querying the
Palleteentities.