public virtual async Task <TEntity> AddAsync(TEntity item) { using (var transaction = Context.Database.BeginTransaction()) { try { var propertyInfo = item.GetType().GetProperty("LastModifiedDate"); if (propertyInfo != null) { propertyInfo.SetValue(item, DateTime.Now); } Context.Set <TEntity>().Add(item); await Context.SaveChangesAsync(); transaction.Commit(); return(item); } catch (Exception ex) { transaction.Rollback(); throw new Exception(ex.Message); } } }