Based on our discussion, the issue can be resolved by following unit testing best practices. I recommend introducing the repository pattern instead of calling DbContext directly in the controller. This allows you to move your LINQ queries into a dedicated repository method that is accessed through an interface.
By depending on an interface rather than DbContext, you can easily mock the repository in your test [Setup] and control its return values. This removes the exceptions you encountered, which occur because certain EF Core and LINQ operations cannot be mocked directly when using DbContext.
Using the repository pattern leads to cleaner, more testable code and avoids these mocking limitations