Linq to Entities many to many selection: How to force the generation of a JOIN instead of a subselect clause?
问题 Using EF DB first I have two entities (Supplier, Product) that have a many-to-many relationship. Entity Framework does not create an entity for the associated table (SupplierProduct) as the associated table contains only the primary keys of the strong entities. I have been getting all Suppliers that do not supply a given product with the following query: var q1 = context.Suppliers.Where(s=>!s.Products.Any(p=>p.Id == 1)); The SQL produced uses an EXISTS dependent subquery similar to this: