dotnet / dotnet/EntityFramework.Docs

Error when querying temporal table through a mapped Sql Function

Open
#4,415 7 comments 0 reactions 0 assignees View on GitHub
area-model-building
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

I have a temporal table in my database that I'm using in a Sql TVF. I've also associated the sql function to a C# method. When I call that method through EF, the PeriodStart & PeriodEnd date are always looked for by EF.
`Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'PeriodEnd'.
Invalid column name 'PeriodStart'`

I've stripped back the TVF to be a simple statement, with explicit column references instead of Select * and EF still looks for the temporal columns. As a test, I removed the temporal status and the function mapping performs correctly.

Steps to recreate:

1. Add a simple sql tvf to select data from a table, mapped to a C# method.
2. Call the c# method from the context, it should return results
3. Change the table to temporal
4. Repeat 2, the method call will fail with the Invalid Column Name error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.