I'm getting this exception:

System.InvalidOperationException was unhandled
  Message=Can not commit a transaction: ValidationContext is in inconsistent state.
       at Xtensive.Orm.Transaction.CompleteValidation()
       at Xtensive.Orm.Transaction.Commit()
       at Xtensive.Orm.TransactionScope.Dispose()
       at InconsistentState.Model.SessionTrace.TraceOpenedSession(Domain domain, Guid guid, String userId, String ipAddress) 
       at InconsistentState.Program.Main(String[] args)

with this code:

  public class SessionTrace : Entity
    public static void TraceOpenedSession(Domain domain, Guid guid, string userId, string ipAddress)
      using (Session session = domain.OpenSession())
      using (TransactionScope t = session.OpenTransaction())
        SessionTrace sessionTrace = new SessionTrace(session, guid);
        sessionTrace.OpenedDate = DateTime.Now;
        sessionTrace.UserIdentifier = userId;
        sessionTrace.IpAddress = ipAddress;


    private SessionTrace(Session session, Guid sessionId)
      : base(session, sessionId)

    [Field, Key]
    public Guid Id { get; private set; }

    public DateTime? OpenedDate { get; set; }

    public string UserIdentifier { get; set; }

    [Field(Length = 50)]
    public string IpAddress { get; set; }

    public DateTime? ClosedDate { get; set; }

Is this a bug? Am I doing something wrong?

DO.Net version:

asked Mar 16 '12 at 10:16

olorin's gravatar image


Hello olorin,

could you try making constructor of SessionTrace non-private?

(Mar 16 '12 at 10:51) Dmitri Maximov Dmitri%20Maximov's gravatar image

Hello Dmitri, This is working like a charm with a protected constructor.

(Mar 16 '12 at 12:32) olorin olorin's gravatar image

Would it count as a workaround?

(Mar 16 '12 at 13:31) Dmitri Maximov Dmitri%20Maximov's gravatar image

Yes it counts!

(Mar 20 '12 at 11:53) olorin olorin's gravatar image

One Answer:

So, the solution is not to use private constructor for persistent entities.

answered Mar 23 '12 at 05:45

Dmitri%20Maximov's gravatar image

Dmitri Maximov

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA