title: Internal access for entities in Entity Framework makes simple linq where query crash
body: <p>I am developing a library which use EF for database access. To avoid expose the entities outside the library, I have set the access of all tables to internal (I have also set to internal the Entity Container Access). The problem is that now, inside the library, when I try to get an entity by its id, the <code>Where</code> query throws an exception, I do not why.</p>
  
  <p>The internal access has been set in the diagram (.edmx file), and in a static class that I am using as a factory inside the library I have something like this:</p>
  
  <pre><code>var id = 1234;
  var mec = new MyEntitiesContainer();
  var myEntity = mec.MyEntities.Where(e =&gt; e.MyEntitiesId == id).FirstOrDefault();
  </code></pre>
  
  <p>Simple where query to get a concrete entity (row) from the database by its id.</p>
  
  <p>When all entities class access are public, there is no problem, but when I have set them to internal this exception is thrown:</p>
  
  <pre><code>System.ArgumentNullException: Value cannot be null.  Parameter name: source     
      at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
  </code></pre>
  
  <p>Any suggestions?</p>