Support for Table Valued Functions in EF6 Code First?
entity-framework, entity-framework-6
Solution
This is now possible. I created a custom model convention which allows using store functions in CodeFirst in EF6.1. The convention is available on NuGet http://www.nuget.org/packages/EntityFramework.CodeFirstStoreFunctions. Here is the link to the blogpost containing all the details: http://blog.3d-logic.com/2014/04/09/support-for-store-functions-tvfs-and-stored-procs-in-entity-framework-6-1/
Problem
Is it possible to call a TVF in EF6 Code First? I started a new project using EF6 Database first and EF was able to import a TVF into the model and call it just fine. But updating the model became very time consuming and problematic with the large read-only db with no RI that I'm stuck dealing with. So I tried to convert to EF6 code first using the Power Tools Reverse Engineering tool to generate a context and model classes. Unfortunately the Reverse Engineering tool didn't import the TVFs. Next I tried to copy the DBFunctions from my old Database First DbContext to the new Code First DbContext, but that gave me an error that my TVF: "cannot be resolved into a valid type or function". Is it possible to create a code first Fluent mapping for TVFs? If not, is there a work-around? I guess I could use SPs instead of TVFs, but was hoping I could use mostly TVFs to deal with the problematic DB I'm stuck with. Thanks for any work-around ideas