using Microsoft.EntityFrameworkCore;
public static void Main()
using var context = new Context();
var query = context.Items.Where(i => i.Dt.Date > DateTime.Now.AddDays(-61).Date).GroupBy(i => i.Id).Select(i => i.Key);
Console.WriteLine(query.ToQueryString());
public int Id { get; set; }
public DateTime Dt { get; set; }
public class Context : DbContext
public DbSet<Item> Items { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
.UseMySql("server=localhost", MySqlServerVersion.LatestSupportedServerVersion)
.EnableSensitiveDataLogging();