https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/
I tried to use Moq to mock the DbContext and IQueryable<>, but it seems to be really complicated. It’s also not recommended by Microsoft.
For unit testing, it’s recommended to use a real database, perhaps using an in-memory database or a temporary sqlite database. Whatever the type of database you use, install the required NuGet package.