I am using Fluent NHibernate to map out an existing database. For this reason – automapping isn’t an option for me.
How do I tell NHibernate not to map certain properties? Many of them are read-only, and the others do not need to be persisted for other reasons.
I am writing this in VB.Net.
I get the typical error message:
“The following types may not be used as proxies
… should be ‘public/protected virtual’ or ‘protected internal virtual'”
I have purposely not made my objects Overridable (equivalent to virtual in C#) because I do not want NHibernate to touch them.
How can I achieve this?
All properties and methods must be overridable in order for NHibernate to create dynamic proxies, including unmapped properties. This does not imply that NHibernate is mapping your read-only properties, it just requires them to be overridable so that it can generate a proxy of the class. This article explains the requirement.