0
votes

I am trying to map a class hierarchy which looks like this:

public abstract class A { }
public class B : A { }
public class C : A { }

I don't want to map class A because it is abstract, I know I can do:

.IgnoreBase<A>()

to not map A and map all properties of A in B and C. But my problem is that I also have another class D which looks like following:

public class D {
  public virtual A a { get; set; }
}

Now, when I try to map with fluent nhibernate auto mapping feature I get an error that class D refers to an unmapped class A, though class A is actually mapped through subclasses B and C.

Anyone know how to solve this?

1

1 Answers

3
votes

If you don't map class A the classes B and C won't be subclasses. They are just two classes that are not connected at all. NHibernate knows nothing about class A, so how should NHibernate know how to handle references to class A?

Not mapping A because it's abstract is no reason. You can map interfaces too.

Maybe it would be more clear what you want to do if you show us your DB model (tables).