Must be reducible node

This is a strange error indeed. There are similar reports but they don't sound related. It could be that your database doesn't have enough data (or no opportunity status which is 'Won'?).

Anyway you can try calling ToList() right before GroupBy() to eliminate entity framework issues:

var stats = context.Opportunities
.Include(opportunity => opportunity.OpportunityStatus)
.Where(opportunity => opportunity.OpportunityStatus.Name == "Won")
.ToList() // <--- new code
.GroupBy(opportunity => new DateTime(opportunity.CloseDate.Year, opportunity.CloseDate.Month, 1))
.Select(group => new
{
Month = group.Key,
Revenue = group.Sum(opportunity => opportunity.Amount),
Opportunities = group.Count(),
AverageDealSize = group.Average(opportunity => opportunity.Amount),
Ratio = ratio
})
.OrderBy(deals => deals.Month)
.Last();