You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
entity UserRole (UserRoleIdentifier - composite key described below, User, Role)
entity AppUserRole - extends the UserRole class
entity AppUserRole - one to many - UserRoleAdministrativeUnit
UserRoleIdentifier
public virtual int UserId { get; set; }
public virtual int RoleId { get; set; }
The following code defines the one-to-many relation.
[Serializable]
public class AppUserRole : UserRole
{
public virtual IList UserRoleAdministrativeUnits { get; set; }
}
public class AppUserRoleMap : SubclassMap<AppUserRole
{
public AppUserRoleMap()
{
HasMany(u => u.UserRoleAdministrativeUnits).KeyColumns.Add("UserId", "RoleId").Cascade.Delete().Inverse();
}
}
There is an crash on this configuration when Fluent initializes: collection foreign key mapping has wrong number of columns: Business.Model.UsersManagement.AppUserRole.UserRoleAdministrativeUnits type: component[UserId,RoleId]
Stack Trace:
[MappingException: collection foreign key mapping has wrong number of columns: Business.Model.UsersManagement.AppUserRole.UserRoleAdministrativeUnits type: component[UserId,RoleId]]
NHibernate.Mapping.Collection.Validate(IMapping mapping) +390
NHibernate.Cfg.Configuration.ValidateCollections() +121
NHibernate.Cfg.Configuration.Validate() +38
NHibernate.Cfg.Configuration.BuildSessionFactory() +74
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +73
[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
Database was not configured through Database method.
]
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +117
Common.Library.NHibernate.Data.HibernateManager.Initialize() in d:\Projects\Infobest.Library\src\Projects\Components\Common.Library.NHibernate.Data\HibernateManager.cs:125
Web.MvcApplication.Application_Start() in d:\Projects\3R\Development\RALInterfaceEditor\Web\Global.asax.cs:52
The text was updated successfully, but these errors were encountered:
I see. Can you post full code of your example please (entities, mapping, conventions, configuration, helpers, etc)? If it's not a OSS project, you can email me (email address from my github profile)
I have the following scenario:
UserRoleIdentifier
public virtual int UserId { get; set; }
public virtual int RoleId { get; set; }
The following code defines the one-to-many relation.
[Serializable]
public class AppUserRole : UserRole
{
public virtual IList UserRoleAdministrativeUnits { get; set; }
}
public class AppUserRoleMap : SubclassMap<AppUserRole
{
public AppUserRoleMap()
{
HasMany(u => u.UserRoleAdministrativeUnits).KeyColumns.Add("UserId", "RoleId").Cascade.Delete().Inverse();
}
}
There is an crash on this configuration when Fluent initializes:
collection foreign key mapping has wrong number of columns: Business.Model.UsersManagement.AppUserRole.UserRoleAdministrativeUnits type: component[UserId,RoleId]
Stack Trace:
[MappingException: collection foreign key mapping has wrong number of columns: Business.Model.UsersManagement.AppUserRole.UserRoleAdministrativeUnits type: component[UserId,RoleId]]
NHibernate.Mapping.Collection.Validate(IMapping mapping) +390
NHibernate.Cfg.Configuration.ValidateCollections() +121
NHibernate.Cfg.Configuration.Validate() +38
NHibernate.Cfg.Configuration.BuildSessionFactory() +74
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +73
[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
]
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +117
Common.Library.NHibernate.Data.HibernateManager.Initialize() in d:\Projects\Infobest.Library\src\Projects\Components\Common.Library.NHibernate.Data\HibernateManager.cs:125
Web.MvcApplication.Application_Start() in d:\Projects\3R\Development\RALInterfaceEditor\Web\Global.asax.cs:52
The text was updated successfully, but these errors were encountered: