Support for Table Valued Functions in EF6 Code First?

entity-framework entity-framework-6

Question

Can a TVF be called in EF6 Code First?

I first created a new project using EF6 Database, and EF was able to easily import and call a TVF into the model.

But due to the size of the read-only, non-RI database I'm forced to work with, upgrading the model becomes exceedingly time-consuming and difficult.

So, using the Power Tools Reverse Engineering tool to create a context and model classes, I initially tried to convert to EF6 code.

Unfortunately, the TVFs were not imported by the reverse engineering tool.

I then attempted to copy the DBFunctions from my previous Database First DbContext to the new Code First DbContext, but that failed with an error stating that my TVF: "cannot be resolved into a valid type or function."

Can a code-first Fluent mapping be created for TVFs?

Is there a workaround if not?

I suppose I could use SPs in place of TVFs, but I was hoping I could deal with the issue DB I'm stuck with primarily using TVFs.

Thank you for sharing any solutions.

1
15
2/13/2014 11:50:05 PM

Popular Answer

Now, it is feasible. I developed a unique model convention that enables CodeFirst in EF6.1 to use store functions. The convention is offered by NuGet package http://www.nuget.org/packages/EntityFramework.CodeFirstStoreFunctions. Here is a link to the blog post with all the information: http://blog.3d-logic.com/2014/04/09/support-for-store-functions-tvfs-and-stored-procs-in-entity-framework-6-1/

12
4/10/2014 2:43:27 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow