This project is read-only.


Code First: Support function imports


If we don't end up supporting Function Imports on DbContext in EF6 then we should add ExecuteFunctionAsync to ObjectContext. If we move this issue out of EF6 then make sure we open a new issue to add that method.

Enable function imports in Code First.

High level aspects:
  • DbModelBuilder FI design
  • DbContext call usage patterns
  • Update serializers
  • Update validators
  • Entity results
  • Scalar results
  • Complex type results
  • Void functions
  • TVFs
  • Multiple result-sets
  • InOut/Out parameters
Closed Dec 12, 2016 at 10:26 PM by RoMiller
EF Team Triage: We are transitioning this project to GitHub ( As part of this transition we are bulk closing a large number of issues in order that our new issue tracker will accurately reflect the work that our team is planning to complete on the EF6.x code base.

Moving forwards, our team will be fixing bugs, implementing small improvements, and accepting community contributions to the EF6.x code base. Larger feature work and innovation will happen in the EF Core code base ( Closing a feature request in the EF6.x project does not exclude us implementing the feature in EF Core. In fact, a number of popular feature requests for EF have already been implemented in EF Core (alternate keys, batching in SaveChanges, etc.).

This is a bulk message to indicate that this issue was closed and not ported to the new issue tracker. The reasons for not porting this particular issue to GitHub may include:
  • It was a bug report that does not contain sufficient information for us to be able to reproduce it
  • It was a question, but sufficient time has passed that it's not clear that taking the time to answer it would provide value to the person who asked it
  • It is a feature request that we are realistically not going to implement on the EF6.x code base
    Although this issue was not ported, you may still re-open it in the new issue tracker for our team to reconsider ( We will no longer be monitoring this issue tracker for comments, so please do not reply here.


ctaggart wrote Nov 30, 2013 at 12:15 AM

Is this the best issue to vote for code first TVFs? I just converted a big EF5 project to code first, only to find out that the TFVs are not composable from EF5 or EF6. :( Now, I get to spend my weekend converting it back. Any chance we can get this in 6.1? Also, it would be good to chime in on this stackoverflow question.

bmrpatel wrote Dec 9, 2013 at 2:54 PM

Every major release EF looks promising and I then I try to convert my linq to sql model to EF Code First. Unfortunately I find that there are limitations and need to wait. :(

Current limitation is function import feature.

My Goal Linq2SQL -> Completely EF code first:

Only one definition for all the entities and use it across multiple context.
define all the sql function import in different context and return entities defined.

definition like this would be great:
[DbFunction("FX_GetCustomer")] //or using OnModelCreating 
public IQueryable<Customer> GetCustomer(parameters....)
   //call the function FX_GetCustomer and return the composable result

drmcclelland wrote Jan 9, 2014 at 10:44 PM

We too would love to be able to convert our LINQ to SQL code to EF Code First! Being able to EF6 Code First with Insert/Update/Delete stored procedures for "CUD" is great, we're just missing the "R" in "CRUD" to be ready to move!

jordangray wrote Feb 14, 2014 at 11:19 AM

Currently facing a scenario where a TVF is the best way of doing what I want, but after a few hours I can't find an obvious way to use one with a code-first model. It would be very nice if they could be supported down the line! :)

moozzyk wrote Feb 14, 2014 at 7:22 PM

Please see this thread: and this project: (note that this is work in progress but is in usable state right now)

jordangray wrote Feb 14, 2014 at 10:56 PM

Pawel—thank you so much, that looks like exactly the thing I need! I'll check it out when I'm back in the office on Monday.

moozzyk wrote Apr 10, 2014 at 3:30 PM

I finally published the convention that allows using TVFs and SProcs in EF6.1 Code First on NuGet. Here is the link: and here is the link to the blogpost containing all the details: