dancis
dancis
CC#
Created by dancis on 1/20/2024 in #help
I'm getting "specified method is not supported" when I include a specific navigation property with e
I'm using ASP.NET Core Identity with a custom IdentityUser that looks like this: public class ApplicationUser : IdentityUser { public string? FirstName { get; set; } public string? LastName { get; set; } public IEnumerable<Subject> Subjects { get; set; } = Enumerable.Empty<Subject>(); } My Subject class looks like this: public class Subject : BaseEntity { public string Name { get; set; } = ""; public ICollection<ApplicationUser> Users { get; set; } = new List<ApplicationUser>(); } It's a m:n relationship that is working fine. I just can't include Subjects from my ApplicationUser and I can't include Users from my Subject. I can include everything else, just not that. I always get following error: System.NotSupportedException: Specified method is not supported. I am including it like this: await this._context.Subjects.Include(subj => subj.Users).ToListAsync() await this._context.Users.Include(user => user.Subjects).ToListAsync(); However whenever I use AutoMappers ProjectTo extension, it somehow works: await this._context.Set<ApplicationUser>() .Include(user => user.Subjects) .ProjectTo<UnoccupiedStudentDto>(this._mapper.ConfigurationProvider) .ToListAsync(cancellationToken); What am I missing here?
14 replies