'The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties

Error-> The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.\r\nParameter name: path

Result wanted -> get the category by given id and list of top 5 books related to that id which are active in Books table

Code ->

return dbContext.Categories
   .Include(x => x.Books.Where(book => book.is_active == true).ToList().Take(5))
   .Where(x => x.id == Id && x.is_active == true)
   .FirstOrDefault();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source