title: Entity Framework 6 Code First Custom Functions
body: <p>I'm trying something similar to this:</p>
  
  <p><a href="https://stackoverflow.com/questions/12481868/how-to-use-scalar-valued-function-with-linq-to-entity">How to use scalar-valued function with linq to entity?</a></p>
  
  <p>However I'm not using EDMX, but instead just DbContext and code first.</p>
  
  <p>I've come across this:</p>
  
  <p><a href="https://codefirstfunctions.codeplex.com/" rel="noreferrer">https://codefirstfunctions.codeplex.com/</a></p>
  
  <p>But the usage isn't suitable. What I am trying to achieve is to be able to do this:</p>
  
  <pre><code>var locations = context.Locations.Where(e =&gt; Functions.LatLongDistanceCalc(e.Lat, e.Long, lat, long) &gt;= 10)
  </code></pre>
  
  <p>Where it will call a scalar function (LatLongDistanceCalc) on SQL Server.</p>
  
  <p>Is there any way to do this without using EDMX? I know that you can construct a manual query but this wouldn't be prefereable because I want to bring back entities with lazy loading proxies etc as well as building up a more complex query.</p>