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

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
779 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 46,031 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.

    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

    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.