I get the error as soon as I have any class inheriting from Page in any assembly but the main assembly. I have tested with even the simplest one without any properties/methods on its own.
On 19 Jan, 17:21, Kenneth Cochran <[email protected]> wrote: > Do you know which subclass of Page its choking on? Also I've found > enabling nhibernate logging to be tremendously helpful in finding the > cause of errors so make sure to turn it on if you haven't already. > > On Jan 19, 4:57 am, Mattias <[email protected]> wrote: > > > Here is the stackoverflow > > question:http://stackoverflow.com/questions/2077785/fluent-nhibernate-automap-... > > > What I need to do is automap subclasses of my abstract page class. I > > need to find them in a list of assemblies that I get a runtime (at the > > initialization stage). I don't have any reference to the assemblies > > from the assembly of my mappings. > > > My page class looks something like this: > > > public abstract class Page : EntityBase > > { > > public virtual int Id { get; protected set; } > > public virtual Page Page { get; set; } > > //Other properties > > > } > > > My mappings looks like this: > > > var persistenceModel = new AutoPersistenceModel(); > > _assemblies.ForEach(x => persistenceModel.AddEntityAssembly(x)); > > persistenceModel.Setup(x => > > { > > x.SubclassStrategy = y => SubclassStrategy.Subclass; > > x.DiscriminatorColumn = y => "Type"; > > }) > > .IncludeBase(typeof(Page)) > > .OverrideAll(x => x.IgnoreProperties(y => typeof(Page) > > .IsAssignableFrom(y.ReflectedType) && y.ReflectedType != typeof > > (Page))) > > .Where(y => typeof(EntityBase).IsAssignableFrom(y)); > > > _assemblies is a list of assemblies to search for mappable entities > > in. It contains the assembly of my page class as well as one or more > > other assemblies that all have a reference to the base assembly (the > > one with my page class). > > > When I add a class that inherits from my page class to the same > > assembly as my page class all works fine and its mapped appropriately. > > But if I add one to one of the other assemblies that are loaded at > > runtime I get problems. I get this error: > > > "Tried to add many-to-one 'Page' when already added." > > > It finds the class but for some reason tries to map it as Page or > > something. But the page class is already mapped so I get that error. > > That is my guess. Does anyone know if I can work around this in any > > way? Or know a solution?
-- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
