I have several entities to access the same table. I would like to put them in a class hierarchy. I don't want nhibernate to generate any joined-subclasses or discriminators in the mapping. When I return IsDiscriminated = false it makes joined subclasses which I don't need (and tries to schema export them).
I tried to use
public class SimpleFormConventions : IClassConvention, IClassConventionAcceptance
{
public void Apply(IClassInstance instance)
{
instance.SchemaAction.None();
instance.ReadOnly();
}
public void Accept(IAcceptanceCriteria<IClassInspector> criteria)
{
criteria.Expect(x => Check(x.EntityType));
}
public static bool Check(Type type)
{
string typeName = type.FullName;
string ns = type.Namespace;
typeName = typeName.Substring(ns.Length + 1);
return typeName.StartsWith("SimpleForm+");
}
}
It runs correctly but the schema export ignores it and still tries to export these classes.. How can I achieve that each class is just treated as "flatten" to not generate joined-subclasses in the mapping? How can I disable schema export for these "SimpleForm" nested classes?
I moved all my hierarchy to abstract classes and set each entity to inherit the corresponding class from that hierarchy. As my ShouldMap ignores abstract classes now it works.