title: Asp.Net MVC Entity Pass values from database by id and assign as variable
body: <p>What im trying to do here is to get value from my database by its id and have that value set so i can use to make calculation with. So i have id set as 1 and i have money and i want to do something like SELECT Balance FROM My_Table WHERE Id = 1; Is there a way to do this just by using the entity framework?</p>
  
  <p>What i have done so far is.</p>
  
  <p>In my DbEntity Model class.</p>
  
  <pre><code>public partial class CurrentAccount
  {
      public int Id { get; set; }
      public decimal Balance { get; set; }               
  }
  </code></pre>
  
  <p>In my controller.</p>
  
  <pre><code>public class YourAccountsController : Controller
  {
      // GET: YourAccount
      public ActionResult CurrentAccount(CurrentAccount ca)
      {
          return View(ca.Balance);
      }
  }
  </code></pre>
  
  <p>Not worrying to much about the view atm as i can see when Balance has been assigned a db value in my locals and atm balance is set as 0.</p>
  
  <p><a href="https://i.stack.imgur.com/fFZLH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fFZLH.jpg" alt="enter image description here"></a></p>