I am trying to get the number of subjects each student have using the below query:
var selectedSubject = context.Students
.Include(d => d.Subjects)
.Select(dr => new
{
Name = dr.Student.FirstName,
NoOfSubject = dr.Subjects.Count
})
.ToList();
But I am getting an exception
An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll
Additional information: The specified type member 'Subjects' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported
Subjectsis not queryable.