I have a doubt, the _context.Database.ExecuteSqlCommandAsync
method autocommit a transaction or not.
My code looks like this:
using (DatabaseContext _db = new DatabaseContext())
{
using(var _transaction = _db.Database.BeginTransaction())
{
try
{
await _db.Database.ExecuteSqlCommandAsync(query, paramsList);
_transaction.Commit();
}
catch(Exception ex)
{
_transaction.Rollback();
throw;
}
}
}
I assume that method doesn't auto commit the transaction, so I decided to commit it manually.
Is a good practice?, or is not necessary doing this?