I'm using Entity Framework and database first. Is it possible to generate entities that exposes readonly properties for navigation properties? If that is possible is it still possible to use eager loading?
Asked
Active
Viewed 139 times
0
-
take a look at this http://stackoverflow.com/questions/12798502/entity-framework-entity-read-only-property-mapped-to-a-column-of-related-table – Ehsan Feb 14 '14 at 13:16
1 Answers
0
Do you mean something like this?
public class MyEntity
{
public virtual OtherEntity Other { get; protected set; }
}
While technically not readonly, your code is unable to set this property. You can still eager load it though because the accessor is public -- only the mutator is protected, which means you can't access it unless you are a member in the class or overriding the class.
Update:
EF does not yet support ReadOnlyCollection properties, but there may be a workaround here.
-
-
@ErikZ, technically those are not Navigation properties, they are Collection properties. No it is not possible (yet) to have readonly collection properties. – danludwig Feb 14 '14 at 18:07
-