title: Issue with Linq, NpqSql and Entity Framework on one machine only
body: <p>We have an environment that has been successfully running a postgresql web application with 
  Entity Framework running on .net 4.0.  </p>
  
  <p>Somehow, on my machine only, a single Linq query fails where on others it is successful.  The following is the linq query, context of which doesn't particularly matter.  Point is, it works on other machines and not mine.  Additionally, my machine can successfully do inserts and the like but not this one specific execution.</p>
  
  <pre><code>((SEntities)Context).c_app.MergeOption = MergeOption.AppendOnly;
  app = (((from rec in ((SEntities) Context).c_application
       where rec.app_id == CStatus.app_id
          select rec) as ObjectQuery&lt;c_application&gt;)
          .Include("c_status")
          .Include("c_tasks")
          .Include("c_product")
          .Include("c_acct")
      ).SingleOrDefault();
  </code></pre>
  
  <p>On co-workers machines, a fresh checkout running in the same server configuration yields a succsful result.</p>
  
  <p>However, on mine, the following is the exception I get:</p>
  
  <blockquote>
    <p>System.Exception {System.Data.EntityCommandExecutionException}</p>
    
    <p>InnerException:<br>
    {"ERROR: 42601: syntax error at or near \"LEFT\""} System.Exception {Npgsql.NpgsqlException}</p>
  </blockquote>
  
  <p>If I look at the errorSQL entry in the debug window that comes up, a huge SQL is created with "select .... limit 2 left join..." which is invalid and where the error is occurring.</p>
  
  <p>The question is, why is this only happening on my machine, and my compiled code deployed to the others and/or the same code executed on co-workers working?  We have recently upgraded to a 64 bit app pool but the DLLs are deployed with it and from the output, are the correct ones.</p>
  
  <p>Obviously I'm missing something on my machine but it's not in our source so its either an iis config or something in the gac that has caused problems.</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>Despite checking, I had installed 4.5 when I did a developer preview install of Visual Studio.  Since 4.5 is an in-place upgrade from 4.0, I was missing everything where it said "target 4.0" despite being 4.5.  Apparently Microsoft fixed a bunch of bugs in 4.5 for Entity Framework (or made more) and this was one of them.  Other people have had similar issues so not sure if it was a bug in 4.0 or a bug introduced in 4.5.</p>
  
  <p>The following fixed the above for anyone who somehow may have</p>
  
  <pre><code>string sql = "SELECT VALUE a FROM c_application AS a WHERE a.app_id = @appId";
  ObjectParameter[] queryParams = { new ObjectParameter("appId", CStatus.app_id) };
  ObjectQuery&lt;c_application&gt; query = Context.CreateQuery&lt;c_application&gt;(sql, queryParams).Include("c_status").Include("c_tasks").Include("c_product").Include("c_acct");
  CApplicationDao cApplicationDao = new CApplicationDao();
  SetupDao&lt;c_application&gt;(cApplicationDao);
  query.MergeOption = MergeOption.AppendOnly;
  app = credApplicationDao.FindSingle(query);
  </code></pre>