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 Where
query throws an exception, I do not why.
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:
var id = 1234;
var mec = new MyEntitiesContainer();
var myEntity = mec.MyEntities.Where(e => e.MyEntitiesId == id).FirstOrDefault();
Simple where query to get a concrete entity (row) from the database by its id.
When all entities class access are public, there is no problem, but when I have set them to internal this exception is thrown:
System.ArgumentNullException: Value cannot be null. Parameter name: source
at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
Any suggestions?