© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
24 replies
Dropps

✅ System.NotSupportedException with EF Core

quick question:

public async Task<List<Order>> GetAllOrders()
    {
        return await _dbContext.Orders
            .Include(o => o.OrderFoods!)
            .ThenInclude(of => of.Food)
            .ToListAsync();
    }
public async Task<List<Order>> GetAllOrders()
    {
        return await _dbContext.Orders
            .Include(o => o.OrderFoods!)
            .ThenInclude(of => of.Food)
            .ToListAsync();
    }

gives me a NotSupportedException but how do i fix that?

dataclass:
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

#pragma warning disable CS8618
namespace iFoodTracker.Models;

public class Order
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid Id { get; set; }
    public DateTime CreatedAt { get; set; }
    public bool PaidStatus { get; set; }
    public string UserId { get; set; }
    public string? EmployeeShort { get; set; }
    public IEnumerable<OrderFood>? OrderFoods { get; set; }
}
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

#pragma warning disable CS8618
namespace iFoodTracker.Models;

public class Order
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid Id { get; set; }
    public DateTime CreatedAt { get; set; }
    public bool PaidStatus { get; set; }
    public string UserId { get; set; }
    public string? EmployeeShort { get; set; }
    public IEnumerable<OrderFood>? OrderFoods { get; set; }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

EF Core
C#CC# / help
2y ago
✅ EF Core migrations with Docker
C#CC# / help
11mo ago
Calculated Properties with EF Core
C#CC# / help
2y ago
✅ Soft Deletions with EF Core
C#CC# / help
3y ago