Skip to content
Advertisement

Tag: using

EF Core transaction lifetime

We are using our select statement inside transaction scope because of concurrency concerns. The question is, if I put my transaction in using statement, do I still have to call Commit() method explicitly to be sure that the transaction is closed or Dispose() method will do the job? Here’s example code: Answer The official docs would be your best friend

‘ExecuteNonQuery requires an open and available Connection. The connection’s current state is closed.’ – C#

The code: This error shows up when I click the save button: System.InvalidOperationException: ‘ExecuteNonQuery requires an open and available Connection. The connection’s current state is closed.’ I am using the using keyword, if I’m correct doesn’t using automatically opens and closes the sqlConnection? If so, why does it returns an error that I need an open and available connection for

Advertisement