title: Entity framework. Reloading local data
body: <p>I have a control in WPF app that binds to this property</p>
  
  <pre><code>public ObservableCollection&lt;Entity.Account&gt; Accounts
  {
      get
      {
          _context.Accounts.Load();
          return _context.Accounts.Local;
      }
  }
  </code></pre>
  
  <p>I expected that every time control reaches for data, local collection gets reloaded from scratch from database because of Load() method, but apparently I was wrong.</p>
  
  <p>So I have two questions: what exactly Load() does if it's not loading entities from context to local? And how can i populate local collection by other means but Load()?</p>
  
  <hr>
  
  <p><strong>More details:</strong></p>
  
  <p>First here's how it's bound:<code>&lt;TextBox Text="{Binding Name}"/&gt;</code>
  and in code-behind <code>DataContext = _viewmodel.Accounts;</code></p>
  
  <p>This <em>Accounts</em> property is exactly the one I wrote above. And the <em>Name</em> propery it binds to is a part of Account entity.</p>
  
  <p>If you edit the account's name and won't call EntityContext.SaveChanges() it will change in local collection but won't change in database and calling Load() method won't refresh local collection. It only refreshes when program restarts (when context is created anew)</p>