EF Core how can I access temporal table PeriordStart value to use it for "last modified" information
From the docs:
var validFrom = foo.Property<DateTime>("VALID_FROM").CurrentValue;
This works and i get the correct DateTime for when the row was last modified.
But this is not very nice to do. I would like to be able to access this VALID_FROM via
foo.ModifiedUtc
My temporal definiton
What i've tried:
Decorate the ModifiedUtc property with a [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
But this just ends in an exception: Microsoft.Data.SqlClient.SqlException : Invalid column name 'VALID_FROM1'.
So EF seems to enumerate one of my mappings by adding a 1 after the column name.1 Reply
If anyone ever runs into this. Here was the best solution:
https://github.com/dotnet/efcore/issues/26463#issuecomment-1984046675
GitHub
Allow temporal Period properties to be mapped to CLR properties (i....
(.NET 6, EF Core 6 RC2/latest) I generate the fields in an entity which are mapped to the period fields in a temporal table as readonly properties and map them as normal fields, however when using ...