Take the 2-minute tour ×  I have an application storing a tree
structure and is able to generate the database fine, but when
inserting I get an exception. I simplified the code to narrow
down the problem.  The class to be saved:  public class Node
public virtual int NodeId { get; set; }     public virtual
string Name { get; set; }     public virtual Node Parent { get;
set; }     public virtual IList<Node> Children { get; set; }
This is the mapper code:  public sealed class NodeMap :
ClassMap<Node>     public NodeMap()         Id(n =>
n.NodeId).GeneratedBy.Identity();         Map(n => n.Name);
References(n => n.Parent).LazyLoad().Nullable();
HasMany(n => n.Children).LazyLoad().KeyColumn("ParentId");  When
I do an insert like dataClient.Insert(new Node { Name = "Test"
}); I get an exception saying:
NHibernate.Exceptions.GenericADOException: could not insert:
[Model.Node][SQL: INSERT INTO [Node] (Name, NodeId) VALUES (?,
?); select SCOPE_IDENTITY()]  And the inner exception says:
System.Da