efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Database.BeginTransaction() fails after Database.EnsureCreatedAsync() called

Open xatabhk opened this issue 10 years ago • 2 comments

Error message: begintransaction sqlexception: New transaction is not allowed because there are other threads running in the session

xatabhk avatar Mar 14 '16 14:03 xatabhk

Can you confirm that you are waiting on the call to EnsureCreatedAsync() to complete before calling BeginTransaction()? You can't have two concurrent operations running on a single context instance, so you need to use await, Wait(), etc. to ensure the first call completes before starting a new operation.

If you are waiting for completion, can you share a complete code listing (or project) that we can use to reproduce the issue.

rowanmiller avatar Mar 22 '16 23:03 rowanmiller

@rowanmiller No Wait() on the call. So it is not a bug.

xatabhk avatar Mar 23 '16 02:03 xatabhk