I have a base class that contains a property called IsDirty. This is used for the domain model and is not a column in the database table.
When using automapping, fluent nhibernate tries to add this column to the table. A way to fix this is to put .ForTypesThatDeriveFrom<Address>(p => p.IgnoreProperty(x => x.IsDirty))
in the automapping setup.
The problem is, all my entities will do this, is there a way to state this without have to add this line for every entity? If I put .ForTypesThatDeriveFrom<Entity>(p => p.IgnoreProperty(x => x.IsDirty))
, then I get an error trying to convert Entity to Address.
I also have entity set as the base type.
Thanks in advance, JT
You create a class derived from
DefaultAutomappingConfiguration
and override theShouldMap(Member member)
method.Like so:
and then your fluent configuration will look something like:
I've had the same problem, except that NHibernate complained about a missing class.
I believe you can use the following convention to remove the part that maps the property from the class:
The code I've used is a bit different, since what I needed to remove was a ManyToOne mapping:
I'm not exactly sure if this is the best way to do this. My feeling is that the discoverability part should be overriden with the ability to not even build up the part for unwanted properties, but for now this seems to work.