ralmsdeveloper / EntityFrameworkCore.FirebirdSQL

FirebirdSQL database provider for Entity Framework Core.
Other
44 stars 26 forks source link

Transaction not working ? #52

Open Herium opened 4 years ago

Herium commented 4 years ago

Need to work with transactions , but not working, if i remove transaction code ,works fine

var sms = this.DbContext.SMS.Find(id);
            if (this._validation.DeleteValidation(httpContext, id))
            {
                using (var dbContextTransaction = this.DbContext.Database.BeginTransaction())
                {
                    this.DbContext.SMS.Remove(sms);

                    if (this.DbContext.SaveChanges() == 1)
                    {
                       //error here says the transaction does not exists anymore
                        dbContextTransaction.Commit();
                        return true;
                    }
                    dbContextTransaction.Rollback();
                }

            }