Association references unmapped class

Topics: Administration, Core, General
Aug 10, 2015 at 4:22 AM
Edited Aug 10, 2015 at 4:22 AM
Hi,
I am creating one to many relationship between UsedEquipmentPropertyCategoryPartRecord
and UsedEquipmentPropertyPartRecord.

Below is my code :
public class UsedEquipmentPropertyPartRecord
{
    public virtual int Id { get; set; }
    public virtual IList<UsedEquipmentPropertyCategoryPartRecord> UsedEquipmentPropertyCategoryLists { get; set; }
}
public class UsedEquipmentPropertyCategoryPartRecord
{ 
    public virtual int CategoryId { get; set; }
    public virtual UsedEquipmentPropertyPartRecord UsedEquipmentPropertyPartRecord { get; set; }
}

DataMigration.cs
SchemaBuilder.CreateTable("UsedEquipmentPropertyCategoryRecord", table =>
        {
            table.Column<int>("Id");
            table.Column<int>("UsedEquipmentPropertyPartRecord_Id");
        });
Error:
NHibernate.MappingException: Association references unmapped class: UsedEquipment.Models.UsedEquipmentPropertyCategoryPartRecord
at NHibernate.Cfg.XmlHbmBinding.CollectionBinder.BindCollectionSecondPass(ICollectionPropertiesMapping collectionMapping, Collection model, IDictionary2 persistentClasses, IDictionary2 inheritedMetas) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\XmlHbmBinding\CollectionBinder.cs:line 742
at NHibernate.Cfg.XmlHbmBinding.CollectionBinder.<>c__DisplayClass13.<AddCollectionSecondPass>b__12(IDictionary2 persistentClasses) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\XmlHbmBinding\CollectionBinder.cs:line 448
at NHibernate.Cfg.Configuration.SecondPassCompile() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\Configuration.cs:line 1104
at NHibernate.Cfg.Configuration.GetObjectData(SerializationInfo info, StreamingContext context) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\Configuration.cs:line 142
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at Orchard.Data.SessionConfigurationCache.StoreConfiguration(ConfigurationCache cache) in c:\code\Hitachi\src\Orchard\Data\SessionConfigurationCache.cs:line 83
at Orchard.Data.SessionConfigurationCache.GetConfiguration(Func
1 builder) in c:\code\Hitachi\src\Orchard\Data\SessionConfigurationCache.cs:line 64
at Orchard.Data.SessionFactoryHolder.BuildConfiguration() in c:\code\Hitachi\src\Orchard\Data\SessionFactoryHolder.cs:line 100
at Orchard.Data.SessionFactoryHolder.GetConfiguration() in c:\code\Hitachi\src\Orchard\Data\SessionFactoryHolder.cs:line 78
at Orchard.Data.SessionFactoryHolder.BuildSessionFactory() in c:\code\Hitachi\src\Orchard\Data\SessionFactoryHolder.cs:line 90
at Orchard.Data.SessionFactoryHolder.GetSessionFactory() in c:\code\Hitachi\src\Orchard\Data\SessionFactoryHolder.cs:line 69
at Orchard.Data.SessionLocator.EnsureSession(IsolationLevel level) in c:\code\Hitachi\src\Orchard\Data\SessionLocator.cs:line 94
at Orchard.Data.SessionLocator.Demand() in c:\code\Hitachi\src\Orchard\Data\SessionLocator.cs:line 46
at Orchard.Data.SessionLocator.For(Type entityType) in c:\code\Hitachi\src\Orchard\Data\SessionLocator.cs:line 40
at Orchard.Data.Repository1.get_Session() in c:\code\Hitachi\src\Orchard\Data\Repository.cs:line 27
at Orchard.Data.Repository
1.get_Table() in c:\code\Hitachi\src\Orchard\Data\Repository.cs:line 31
at Orchard.Data.Repository1.Fetch(Expression1 predicate) in c:\code\Hitachi\src\Orchard\Data\Repository.cs:line 151
at Orchard.Data.Repository1.Get(Expression1 predicate) in c:\code\Hitachi\src\Orchard\Data\Repository.cs:line 92
at Orchard.Data.Repository1.Orchard.Data.IRepository<T>.Get(Expression1 predicate) in c:\code\Hitachi\src\Orchard\Data\Repository.cs:line 61
at Orchard.Core.Settings.Descriptor.ShellDescriptorManager.GetDescriptorRecord() in c:\code\Hitachi\src\Orchard.Web\Core\Settings\Descriptor\ShellDescriptorManager.cs:line 56
at Orchard.Core.Settings.Descriptor.ShellDescriptorManager.GetShellDescriptor() in c:\code\Hitachi\src\Orchard.Web\Core\Settings\Descriptor\ShellDescriptorManager.cs:line 29
at Orchard.Environment.ShellBuilders.ShellContextFactory.CreateShellContext(ShellSettings settings) in c:\code\Hitachi\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs:line 66
at Orchard.Environment.DefaultOrchardHost.CreateShellContext(ShellSettings settings) in c:\code\Hitachi\src\Orchard\Environment\DefaultOrchardHost.cs:line 187
at Orchard.Environment.DefaultOrchardHost.<CreateAndActivateShells>b__7(ShellSettings settings) in c:\code\Hitachi\src\Orchard\Environment\DefaultOrchardHost.cs:line 137

Any help will be appreciated .Thanks
Aug 10, 2015 at 7:43 AM
You have named the table "UsedEquipmentPropertyCategoryRecord", while your part record is called "UsedEquipmentPropertyCategoryPartRecord" (see the 'Part'). One way to avoid these kind of things is using strongly typed table names:
SchemaBuilder.CreateTable(typeof (UsedEquipmentPropertyCategoryPartRecord).Name, table =>