Update
As of .NET 6 a new DistinctBy operator has been introduced. However, while this works well for Linq to Objects, it doesn't appear to be working for Linq to Entities. I tested it with EF Core 6.0.6 and SQL server.
Generally speaking, LINQ operators come in pairs to support those two scenarios. For example, Enumerable.Select covers Linq to Objects, Queryable.Select covers Linq to Entities.
Interestingly DistinctBy
has both of those flavors as well, but EF Core's SQL Server provider doesn't support it's translation to SQL. The reason, in my opinion, is that it would result in a slow query.
Original Answer
There are lots of discussions around this topic.
You can find one of them here:
One of the most popular suggestions have been the Distinct method taking a lambda expression as a parameter as @Servy has pointed out.
The chief architect of C#, Anders Hejlsberg has suggested the solution here. Also explaining why the framework design team decided not to add an overload of Distinct method which takes a lambda.