title: EntityFramework Core Subquery
body: <p>I am new to Entity Framework Core and not sure how to translate below SQL query to use EF.  Below is my query:</p>
  
  <pre><code>SELECT *
  FROM Project
  WHERE Project_Id IN(
  
      SELECT Project_Id
      FROM IP
      GROUP BY Project_Id
      HAVING COUNT(Project_Id)&lt;= 2
  )
  
  </code></pre>
  
  <p>I have tried below script, but returns all the records from the project table.</p>
  
  <pre><code>var projs = _context.Project
      .FromSqlRaw("SELECT * FROM Project WHERE Project_Id IN(SELECT Project_Id FROM IP GROUP BY Project_Id HAVING COUNT(Project_Id)&lt;= 2)")
      .ToList();
  
  </code></pre>
  
  <p>Any help is appreciated!</p>