4

I have a Mailclass, where I want to save both the sender and the recipient as a reference to the User class;

    public class dbMail : Entity
{
    public virtual int ThreadID { get; set; }
    public virtual dbUser From { get; set; }
    public virtual dbUser To { get; set; }
    public virtual DateTime MailDate { get; set; }
    public virtual string MailText { get; set; }
    public virtual bool IsRead { get; set; }
}

and the mapping:

<id name="ID">
  <generator class="identity" />
</id>
<property name="ThreadID" />

<many-to-one name="From" class="dbUser" column="From"/>
<many-to-one name="To" class="dbUser" column="To"/>
<property name="MailDate" />
<property name="MailText" type="StringClob">
  <column name="MailText" sql-type="text" />
</property>
<property name="IsRead" />

However, when trying to update the database, this error occurs:

Duplicate property mapping of dbUser found in Domain.Model.dbMail
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
rodael
  • 57
  • 6

1 Answers1

2

I've your same mapping situation and it works. The only difference is:

<many-to-one cascade="all" ...

Try this solution but if this doesn't works you have to show update code and/or dbUser code and mapping for further investigation.

danyolgiax
  • 12,798
  • 10
  • 65
  • 116