An error occured using transaction [20205]

Neeraj Kumar 1 Reputation point
2021-05-12T06:20:35.17+00:00

In my code whenever _content.SaveChagnesAsync() executes I am getting the error

Microsoft.EntityFrameworkCore.Databse.Transaction[20205]
An error occurred using a transaction.

Further looking into the logs I found out few of the time

RelationalEventId.BatchExecutorFailedToReleaseSavepoint [20703]

raises the execption.

Though the data is being saved perfectly in the database, yet I'm getting the error.
So, I cannot understand why this error is coming up again and again.
Please let me know what can be implemented to resolve this issue.

I am using .net core 3.1 for the project, entity-framework-core 5.0.4, oracle for database and repository pattern for data layer.

Developer technologies .NET Entity Framework Core
{count} votes

3 answers

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,651 Reputation points
    2021-05-13T06:54:14.867+00:00

    Hi NeerajKumar-1313,
    You need to use _context.SaveChanges() instead of _context.SaveChangesAsynch. The reason for the error is because the transaction runs asynchronously. When you execute _context.SaveChanges(), the transaction occurs in a commit, and the database connection is not closed and reopened to save the changes.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Kevin N 1 Reputation point
    2021-05-19T07:29:26.373+00:00

    I think you may be observing this issue with Oracle.EntityFrameworkCore.

    If that is the case, it is not related to whether you are using async or not. I have a minimal console app demonstrating the problem without using async methods. Rather, the problem has to do with releasing a transaction save point, which I think has no meaning in Oracle.

    We are currently waiting for the fix that is slated for the next release of Oracle.EntityFrameworkCore, which will probably be version 5.21.2.

    0 comments No comments

  3. JIUWO XIAO 0 Reputation points
    2024-11-22T08:38:01.84+00:00

    remove transaction.commit() from using(...begintransaction()){...savechangesasync();transaction.commit()}

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.