I have been struggling with this NHibernate issue for hours. I extensively researched on the web as well as the NHibernate documentation, and I can make no sense of this issue. I'm relatively new to NHibernate, and love it. In that case, though, it's driving me mad.
I'm writing a small "Poll" module for a website. I have several classes (Poll, PollVote and PollAnswer). The main one, Poll, is the one causing the issue. This this what the class looks like:
public class Poll
{
public virtual int Id { get; set; }
public virtual Site Site { get; set; }
public virtual string Question { get; set; }
public virtual bool Locked { get; set; }
public virtual bool Enabled { get; set; }
public virtual ICollection<PollAnswer> AnswersSet { get; set; }
public virtual ICollection<PollVote> VotesSet { get; set; }
}
And this is what the mapping looks like:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Folke"
namespace="Folke.Code.Domain">
<class name="Poll">
<id name="Id">
<generator class="native"></generator>
</id>
<property name="Site"/>
<property name="Question"/>
<property name="Locked"/>
<property name="Enabled"/>
<set name="AnswersSet" lazy="true">
<key column="PollId"/>
<one-to-many class="PollAnswer"/>
</set>
<set name="VotesSet" lazy="true">
<key column="PollId"/>
<one-to-many class="PollVote"/>
</set>
</class>
</hibernate-mapping>
This returns me an error:
Association references unmapped class: Folke.Code.Domain.PollAnswer Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: NHibernate.MappingException: Association references unmapped class: Folke.Code.Domain.PollAnswer
I really want to understand this, and understand better the inner working of NHibernate. I don't understand how it cannot "see" the PollAnswer" class.