using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
public static void Main()
using (var db = new BloggingContext())
db.Add(new Blog { BlogId = 1, Created = DateTime.UtcNow.AddMinutes(-1) });
db.Add(new Blog { BlogId = 2, Created = DateTime.UtcNow.AddMinutes(10) });
db.Add(new Blog { BlogId = 3, Created = DateTime.Now.AddMinutes(-1) });
db.Add(new Blog { BlogId = 4, Created = DateTime.Now.AddMinutes(10) });
var resultsWithNow = db.Blogs.Where(x => x.Created < DateTime.Now).ToList();
var resultsWithUtcNow = db.Blogs.Where(x => x.Created < DateTime.UtcNow).ToList();
System.Console.WriteLine("Count with now:" + resultsWithNow.Count());
System.Console.WriteLine("Count with utcnow:" + resultsWithUtcNow.Count());
public class BloggingContext : DbContext
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseInMemoryDatabase("demo");
public int BlogId { get; set; }
public DateTime Created { get; set; }