title: Entity framework add where clause to all queries
body: <p>I have a project that is using Entity framework and AspNet Identity.</p>
  
  <p>One of the parameters of the IdentityUser is a deactivated field.</p>
  
  <p>Within the app, if I wanted to get the users, I would do this:</p>
  
  <pre><code>var users = Context.Users //etc....
  </code></pre>
  
  <p>However, I do not want this query to return any deactivated users. I know I could do this</p>
  
  <pre><code>var users = Context.Users.Where(x =&gt; x.Deactivated != true);
  </code></pre>
  
  <p>However, I am reluctant to do this, as I am sure that in time someone will forget to add this where clause.</p>
  
  <p>Is there a way for entity to do this automatically to all context queries? I have found this:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/ef/core/querying/filters" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/querying/filters</a></p>
  
  <p>But I do not have EF core and cannot upgrade to it.</p>
  
  <p>I know I could make a wrapper function and call this, but I am trying to find a better solution...</p>