mockDbFactory.Setup(f => f.CreateDbContext()) .Returns(() => new SomeDbContext(new DbContextOptionsBuilder<SomeDbContext>() .UseInMemoryDatabase("InMemoryTest") .Options));