sql-serverentity-frameworklinq-to-entitiesazure-sql-databasetemporal-database

Use Table Valued Function for EF6 support of temporal queries?


This link describes how to use TVFs with EF6 Database First so they can be used in Linq Queries like an entity for a SQL table.

It would seem possible to create a TVF that would query historical data from a SQL temporal table, and then have that available to Linq queries.

So for example the TVF might have code like this to get its resultset

    select c.Name, c.Age, c.Height, c.Weight from Child c FOR SYSTEM_TIME AS OF '2014-01-01'

The only problem I see is having to remap the TVF every time anyone regenerates the EDMX.

Is there a way to use T4 to automate mapping the TVF to the Child table?


Solution

  • Have a look at EF Reverse POCO to avid EDMX (and enable function mapping) – ErikEJ Jan 24 at 7:36

    Thank you for your answer Erik EJ. I have had a great experience with Simon Hughes' VS Add-in. We had been using EDMX solely to generate a model of the database tables. EF Reverse POCO performs that task with beautiful efficiency, and supports TVF's too for temporal querying.