title: ado.net entity framework "retains" changes despite exiting transaction
body: <p>hi guys I have some logic problem in my code (adonet entity framework)</p>
  
  <p>here's the pseudocode</p>
  
  <pre><code>i = 0
  
  while i &lt; 5
  
     using transactionreadcommited
  
     {
  
       var getuser = (from a in mydb.users where userid.equals(1) select a).firstordefault
  
      try {
  
          getuser.moneyBalance -= 10;
  
         //error here
  
         some command here causing expected error so it goes to catch ;
  
  
          db.savechanges()
          transaction.complete()
  
    }catch{
  
       i = i + 1
  
    }
  
   }
  
  end while
  </code></pre>
  
  <p>the problem is,:</p>
  
  <p>I get a new user in new transaction every time it retries in the while loop</p>
  
  <p>User's initial money balance is 100.I minus 10, so it becomes 90</p>
  
  <p>but if some command fails, it will exit the transaction and retry -</p>
  
  <p>in the 2nd loop, User's money becomes initial 90 - 10 = 80. shouldn't it revert back to 100, since I recreate a new transaction, and have not committed the first loop ?</p>