I would like to retrive data (list of channels for category).
Here's my model:
public class Category : AuditableEntity<int>
{
public string Name { get; set; }
public virtual IEnumerable<CategoryChannel> CategoryChannels { get; set; }
}
public class CategoryChannel : Entity<int>
{
[Display(Name = "Channel")]
public string ChannelId { get; set; }
[ForeignKey("ChannelId")]
public virtual Channel Channel { get; set; }
[Display(Name = "Category")]
public int CategoryId { get; set; }
[ForeignKey("CategoryId")]
public virtual Category Category { get; set; }
}
public class Channel : AuditableEntity<string>
{
public string Name { get; set; }
public virtual IEnumerable<CategoryChannel> CategoryChannels { get; set; }
}
And here's my code for retrive data:
return _entities.Set<Channel>()
.Include(x => x.CategoryChannels).Where(y => y.Name.Equals(category))
.AsEnumerable();
And finally I've got an error message:
A specified Include path is not valid. The EntityType 'xxx.Channel' does not declare a navigation property with the name 'CategoryChannels'.