In my ASP.NET MVC Core 1.1 app, the AddToRoleAsync
call in the last line of the following code is throwing the error: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
This is kind of odd since I don't have any other transaction running on SQL Server or anywhere else. I'm aware of this T-SQL error in general. But I'm not clear why the AddToRoleAsync
call below is throwing this error. Please note the following code did successfully create a user before it threw the error in the next line of code.
List<String> usersList = GetAllUsers();
foreach (string s in usersList)
{
var user = new ApplicationUser { UserName = s, UserRole = "TestRole" };
var result = await _userManager.CreateAsync(user, "testpassword");
if (result.Succeeded)
{
var result_1 = await _userManager.AddToRoleAsync(user, "TestRole");
}
}