In EF 4.3 documentation says:
By default, building a database using Code First does not include private, protected, or internal properties. If you manually included these properties in your model, Code First would ignore any data annotations on those members. This is issue now fixed, and Code First processes the data annotations.
My question is how to included a protected property manully with code first, espically using fluent API?
Look at http://blog.cincura.net/232147-mapping-private-or-protected-properties-with-code-first-efv4-ctp4/ to the comment from Drew Jones. Not entirely clean, but at least something. :)
Or directly http://blog.cincura.net/232731-mapping-private-protected-properties-in-entity-framework-4-x-code-first/.
It is not possible with fluent API because fluent API uses strongly typed approach and because of that all accessibility rules are still in place. Documentation says it should be possible with data annotations but I wasn't able to make it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With