title: Use EdmFunctionAttribute without exposing Entity Framework dependency/implementation details?
body: <p>Is there a good way to leverage <code>EdmFunctionAttribute</code> without introducing a dependency on The Entity Framework/System.Data.Entity.dll?</p>
  
  <p>I thought I could have an interface with a method and a concrete implementation that implements the method using <code>EdmFunctionAttribute</code> to map it to a database function.</p>
  
  <p>I have a context interface <code>IMyContext</code> defined in an assembly and an Entity Framework implementation <code>MyContext</code> in another assembly.</p>
  
  <pre><code>public interface IMyContext
  {
      double SomeFunction(double first, double second);
  
      // other interface details here
  }
  
  public partial class MyContext : IMyContext
  {
      [EdmFunction("MyNamespace", "MyDatabaseFunction")]
      public double SomeFunction(double first, double second)
      {
          throw new NotSupportedException("This method may only be called as part of a LINQ expression.");
      }
  
      // rest of interface implementation here
  }
  </code></pre>
  
  <p>I use a factory (using StructureMap behind the scenes) to get a context instance as the interface type:</p>
  
  <pre><code>using (IMyContext context = ContextFactory.GetNewContext())
  {
      var results = context.Table.Select(t =&gt; context.SomeFunction(t.Col1, t.Col2)).ToList();
  }
  </code></pre>
  
  <p>This throws a <code>NotSupportException</code> saying that LINQ to Entities does not recognize the method 'Double SomeFunction(Double, Double)'.</p>
  
  <p>If I cast the context to the concrete implementation  </p>
  
  <pre><code>using (MyContext context = ContextFactory.GetNewContext() as MyContext)
  {
      ...
  }
  </code></pre>
  
  <p>then it works, but then I am required to specify the concrete implementation, which I do not want to do.</p>
  
  <p>The function doesn't have to be a member of the context class, I just put it there for exploring.</p>