Closed DmitrijOkeanij closed 5 years ago
Do you have stack to determine where it waits?
Here is my code
using (var transaction = new TransactionScope())
{
IdentityResult result = await userManager.CreateAsync(user, model.Password);
await db.Users.Where(x => x.Id == user.Id).Set(x => x.Link, x => x.Id.ToString()).UpdateAsync();
I tried to debug but any times it breakes in different points.
Sometimes it goes to await db.Users.Where(x => x.Id == user.Id).Set(x => x.Link, x => x.Id.ToString()).UpdateAsync();
Sometimes brokes inside IdentityResult result = await userManager.CreateAsync(user, model.Password);
in different places inside it.
I am not understanding it.
I think this is bug of multythreads debugging?
I use Rider for debug and Ubuntu 18.10 to run.
I have only this
System.InvalidOperationException: A TransactionScope must be disposed on the same thread that it was created. at System.Transactions.TransactionScope.Dispose() at My.Controllers.AuthController.Register(NewUserViewModel model) in /path/Controllers/AuthController.cs:line 139 at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
Looks like TransactionScope is not designed for async execution. Microsoft added TransactionScopeAsyncFlowOption.Enabled
to handle it, so you should try it first
All works fine. Thank you! Maybe to add this to doc?
Will do
I have this code
Execution goes inside
userManager.CreateAsync
, and freeze. No exception, no result.