public async Task <bool> DeleteAndAddSKU(List <GoodInfoSKU> skuList) { bool res = false; using (IDbContextTransaction transaction = Database.BeginTransaction(IsolationLevel.ReadCommitted)) { try { List <GoodInfoSKU> removeList = await CurrentDbSet .Where(sku => sku.ShopId == skuList[0].ShopId && sku.GoodInfoId == skuList[0].GoodInfoId) .ToListAsync(); CurrentDbSet.RemoveRange(removeList); await CurrentDbSet.AddRangeAsync(skuList); SaveChanges(); transaction.Commit(); res = true; } catch { transaction.Rollback(); res = false; } } return(res); }