-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
I have been testing the new Temporal Table support in EF Core 6 and I just found out that it doesn't seem to work properly with Owned entity types. Adding/updating/removing entities that have owned entities work just fine, but when I try to get history data with TemporalAll/TemporalAsOf
, it will return the history correctly for the Main Entity but not for the Owned Entity. Returned Owned Entity values are current values, not historical values. If you will look at the generated SQL below, you can see that the FOR SYSTEM_TIME AS OF
is missing from LEFT JOIN
and that's why it's not getting history data for Owned Entities. Is this intended functionality or bug?
I have linked the test project below if it would be of any use.
Main Entity Structure
MainEntity mainEntity = new()
{
Description = "Main entity",
OwnedEntity = new()
{
Description = "Owned entity"
}
};
TemporalAsOf generated query
SELECT
[m].[Id], [m].[Description], [m].[EndTime], [m].[StartTime],
[o].[MainEntityId], [o].[Description], [o].[EndTime], [o].[StartTime]
FROM [MainEntity] FOR SYSTEM_TIME AS OF '2021-10-25T07:57:11.4857200' AS [m]
LEFT JOIN [OwnedEntity] AS [o] ON [m].[Id] = [o].[MainEntityId]
EF Core version: 6.0.0-rtm.21519.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer (SQL Server 15.0.4153)
Target framework: .NET 6
Operating system: Win10
IDE: Visual Studio 2022 17.0
Link to test project