title: Can't use an sql query in Form.Load
body: <p>Im currently trying to get better at SQL and at the moment I'm working on a small Windows Forms program that interacts with a database. I'm using Entity Framework to accomplish this. I've just ran into a problem that I can't seem to solve on my own. I'm trying to populate a ListBox with items from a database table. To do this my intention was to access all entrys in a table during the Form.Load and then add them to the ListBox. The problem I've ran in to is that for some reason the SQL code doesn't seem to execute when I put it in the Form.Load function. It works as intended if I create a button and use it inside the click event, which is why I'm a bit confused. The code is as simple as this:</p>
  
  <p>THIS WORKS:</p>
  
  <pre><code>    private void btnAdd_Click(object sender, EventArgs e)
      {
          dbConnection db = new dbConnection();
  
          var heroes = db.Hero.SqlQuery("Select * from Hero").ToList();
      }
  </code></pre>
  
  <p>THIS DOESN'T WORK:</p>
  
  <pre><code>    private void AddMatchForm_Load(object sender, EventArgs e)
      {
          dbConnection db = new dbConnection();
  
          var heroes = db.Hero.SqlQuery("Select * from Hero").ToList();
      }
  </code></pre>