2
votes

I'm using Entity Framework 6 and I have lazy loading enabled:

enter image description here

When I set my entity class Access to 'public, lazy loading works fine:

enter image description here In the example above, I'm able to navigate from Address to City.

However, if I change the entity class Access to 'internal', then lazy loading stops working and I can no longer navigate from Address to City if I don't eager load City:

enter image description here

enter image description here

Why does lazy loading stop working for internal classes? Is there a way around this?

1

1 Answers

7
votes

The entity must be public, it's a requirement for Entity Framework to be able to inherit from it and create a proxy at runtime (that adds all the EF internal stuff in the overridden virtual navigation properties).

See Requirements for Creating POCO Proxies on MSDN.