I have the inheritance described below:
public abstract class BaseEntity<TId> {....} public abstract class ModelEntity : BaseEntity<Int32>{....} public abstract class AuditableEntity : ModelEntity,IAuditable{....} public class ApplicationUser : AuditableEntity{....} public class SuperUser : ApplicationUser
I am using NHibernate 3.3 and I want to create mappings for this inheritance
public abstract class ModelEntityMap<TEntity> : ClassMapping<TEntity> where TEntity : ModelEntity {...} public class AuditableEntityMap<TEntity> : ModelEntityMap<TEntity> where TEntity : AuditableEntity { ...} public class ApplicationUserMap : AuditableEntityMap<ApplicationUser> {...} public class SuperUserMap : JoinedSubclassMapping<SuperUser>{...}
When the application starts and tries to tune the database, the following exception occurs: Ambiguous mapping for SuperUser Several root objects BaseEntity / ApplicationUser were found
Possible solutions βMerge the mapping of the Entity root in that it represents the real root in the hierarchy β Insert an IModelInspector with logic to detect the real root object.
I used Fluent nhibernate with the same inheritance and worked great with SuperUserMap defined as public class SuperUserMap: SubClassMap {...}
I'm new to displaying Nhibernate code and quite confusing !!!
source share