Have you tried using ClassMapping<T> instead of JoinedSubclassMapping<T>?

RP


On Sunday, February 5, 2017 at 10:18:46 AM UTC, Jeremy Dowling wrote:
>
> I'm attempting to build an ASP.Net MVC 5 web application, using the 
> NHibernate.AspNet.Identity library (through Nuget), with NHibernate 4 as 
> the ORM.
>
> Rather than extending the NHibernate.AspNet.Identity.IdentityUser using 
> the standard "ApplicationUser" where NHibernate has to be used from the 
> application layer, I want to extend a class I labeled as 
> "ChromSimGUI.Models.GUI_EntityUser"
>
> The signature for the class:
>     public class GUI_EntityUsers : IdentityUser, 
> IComparable<GUI_EntityUsers>  { . . . }
>
> The Map By Code class:
>     public class GUI_EntityUsersMap : 
> JoinedSubclassMapping<GUI_EntityUsers>
>     {
>         public GUI_EntityUsersMap()
>         {
>             this.Extends(typeof(IdentityUser));
>             this.Key(k => {
>                 k.Column("UserId");
>                 k.ForeignKey("fk_AspNetUsers");
>                 k.NotNullable(true);
>                 k.OnDelete(OnDeleteAction.Cascade);
>             });
>             this.Property(x => x.FirstName);
>             this.Property(x => x.LastName);
>             this.ManyToOne(x => x.Address, m => {
>                 m.Column("AddressID");
>                 m.Cascade(Cascade.All);
>                 m.Class(typeof(GUI_EntityAddress));
>             });
>         }
>
> I'm attempting to get the mapping for GUI_EntityUsers via:
>         public static HbmMapping GetGUIModelMappings()
>         {
>             System.Type baseEntityType = typeof(IdentityUser);
>
>             var allEntities = new List<System.Type> {
>                 typeof(GUI_EntityUsers)
>             };
>
>             var mapper = new ConventionModelMapper();
>
>             mapper.IsEntity((t, declared) => 
> (baseEntityType.IsAssignableFrom(t) && baseEntityType != t) && 
> !t.IsInterface);
>             mapper.IsRootEntity((t, declared) => 
> baseEntityType.Equals(t.BaseType));
>                         
>             mapper.AddMapping<GUI_EntityUsersMap>();
>
>             return mapper.CompileMappingFor(allEntities);
>         }
>     }
>
> The mappings are configured for a project where I intend all DAL activity 
> to take place.  So, the helper in that class does:
>                         _configuration = new Configuration();
>                         _configuration.Configure();
>                         
> _configuration.AddDeserializedMapping(MappingHelper.GetIdentityMappings(myEntities),
>  
> null); //this gets the NHibernate.AspNet.Identity mappings
>                         _configuration.AddAssembly("ChromSimGUI.Models"); 
> //grabs the hbm.xml mappings
>                         
> _configuration.AddDeserializedMapping(ChromSimGUI.Models.Helper.MappingHelper.GetGUIModelMappings(),
>  
> null); 
>                         _sessionFactory = 
> _configuration.BuildSessionFactory();
>
>
> In the line compiling the mappings for the GUI_EntityUsersMap, I get an 
> error:  "Ambiguous mapping of ChromSimGUI.Models.GUI_EntityUsers. It was 
> registered as root-entity and as subclass for table-per-class strategy"
>
> I'm still relatively new to nHibernate, esp the map by code, and 
> documentation on the web seems to be very limited for this situation.  Any 
> ideas on how to get this to compile?
>
> Thanks
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to