You can call ToString() on a query object (IQueryable<T>).
You can use the Log attribute (since Entity Framework version 6.0), as in ctx.Database.Log = Console.WriteLine;.
Unfortunately, neither of these options is available in Entity Framework Core.
The following command
only delivers the following output: ...