Reputation: 1842
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?
Upvotes: 10
Views: 6345
Reputation: 4150
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/.
Upvotes: 7
Reputation: 364259
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.
Upvotes: 3