Why does the Entity Framework's DbContext.Find() generate a query with select top 2?
问题 Why does the Entity Framework's DbContext.Find() generate a query with select top 2 and a derived table? By definition, the query is looking up by primary key which should be unique. 回答1: Find checks first if the entity with the given key is already in the context. If not it queries the database. Possibly it uses in this case a LINQ query using SingleOrDefault . SingleOrDefault translates to SELECT TOP 2 to be able to throw an exception if the result has more than one entity. So, why doesn't