none
strange error message from entity framework RRS feed

  • Question

  • Hi,

    I use entity framework (on .net 4) to run some stored procedures, today I got this error:

    "Cannot commit or roll back transaction because BeginTransaction has not been called."

    This error message confused me a lot as I didn't really know that I was using transactions,

    The stack trace is:

    StackTrace:    at System.Messaging.MessageQueueTransaction.Abort()
       at FinancialExpress.Diagnostics.Logging.Logging.ProcessLogQueue()
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

    It took me several hours to debug all my codes and realised that the error was triggered by the fact that one sp was using a table that I renamed recently. The sp throws exceptions on sql server side (e.g. xxx table can not be found)

    However, why I see this transaction error? Any chance that entity framework can give me an error message that more closer to the real problem?

    Many Thanks

    Jerry

     

     

    Wednesday, August 3, 2011 9:02 PM

All replies

  • Hi Jerry,

    Welcome!

    SaveChanges operates within a transaction. SaveChanges will roll back that transaction and throw an exception if any of the dirty ObjectStateEntry objects cannot be persisted.

    http://msdn.microsoft.com/en-us/library/bb336792.aspx 

    Thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 4, 2011 8:47 AM
    Moderator
  • Hi,

    Thanks for your reply.

    Will running a stored procedure (basically a select query) trigger this SaveChange? I don't think that I am saving anything at the moment.

     

    Many Thanks

    Jerry

     

     

    Thursday, August 4, 2011 9:15 AM
  • Hi Jerry,

    Thanks for your feedback.

    >>Will running a stored procedure (basically a select query) trigger this SaveChange? I don't think that I am saving anything at the moment.

    The answer is no. Are you using EF in Multi-thread environment? It could be nice if you could provide some code and more information for us. Thanks for understanding.

    Have a nice day. 


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 5, 2011 8:27 AM
    Moderator
  • Hi Jerry,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance. 

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 11, 2011 8:32 AM
    Moderator