This was probably just me, but I was always under the impression the EF had a hard time hydrating objects with private or protected access modifiers. Turns out not to be the case, at least not in EF 6.
I was looking around for solutions, but noticed that all solutions to - what I thought was a - problem, were pretty old. So I wrote a quick test to see how EF behaves nowadays.
Turns out: any access modifier can be hydrated from EF - no problem.
Here's my model:
Here's the roundtrip test - as you can see - the person coming from the database has all the properties set as expected:
Just for visual verification: everything is nicely in the DB. Although that's not what I was worried about.
Wow - I feel like a n00b not knowing this before.
No comments:
Post a Comment