question

NeerajKumar-1313 avatar image
0 Votes"
NeerajKumar-1313 asked DanielFasogbon-3548 commented

An error occured using transaction [20205]

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.



dotnet-entity-framework-core
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So, you are saying you are using EF Core 5 in a .NET Core 3 project? What do you mean by data layer? Is it a classlib project?

0 Votes 0 ·

Yes, I have seperated out the data layer in a Class library project which is referenced in a .net core web api project.

0 Votes 0 ·

Is this MS SQL Server or some other DB technology?


0 Votes 0 ·
Show more comments

Hi @NeerajKumar-1313,
May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.
Best Regards,
Daniel Zhang

0 Votes 0 ·
DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered DanielFasogbon-3548 commented

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IIt worked man thank you very much

0 Votes 0 ·
KevinN-2798 avatar image
0 Votes"
KevinN-2798 answered KevinN-2798 edited

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.