Share via

managing transaction to avoid deadlock

mehmood tekfirst 771 Reputation points
2022-07-04T14:16:14.44+00:00

Hi,

I want to perform a quick transaction using ef core 6.

This mechanism should be defined in such a way that a deadlock 'll never be happened/occured.

In my code logic, I am sometimes inserting in database entities through

_dbcontext.payments.add( new payment(){amount=20});   

and there are some updates and the remaining ones are related to stored procedures call.

inserts and updates in it.

Can anyone suggest me some excellent way to implement a transaction or a best way to avoid deadlocks/blocking here.

I want to complete the commit to either complete or revert/abort the work.

Thank you so much

Developer technologies | .NET | Entity Framework Core

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,621 Reputation points
    2022-07-05T07:38:08.467+00:00

    I am just worrying about deadlock when I 'll use transaction.

    What's the data destination, a MS SQL Server or ...?
    You can not completly avoid deadlocks, they happens in real world.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. mehmood tekfirst 771 Reputation points
    2022-07-05T09:34:36.28+00:00

    Sql server

    Was this answer helpful?

    0 comments No comments

Your answer

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