Description
Oracle has a type TIMESTAMP WITH TIME ZONE
, and it is recommended to use the TZR TZD format, which looks like this as a PL/SQL literal:
TIMESTAMP '1999-10-29 01:30:00 America/Los_Angeles PDT'
The appropriate .NET type for timestamp supported by Oracle EF Provider is DateTimeOffset
. The problem is, DateTimeOffset
has no way to specify TZR (such as America/Los_Angeles) and neither TZD (such as PDT in the example above).
There exists the OracleTimestampWithTimezone
in Oracle ADO.NET driver, which does support specifying DateTime
+ timezone, for example:
var connection = db.Database.GetDbConnection();
connection.Open();
using var param = new OracleParameter();
param.OracleDbType = OracleDbType.TimeStampTZ;
param.Value = new OracleTimeStampTZ(DateTime.Parse("1999-10-29 01:30:00"), "America/Los_Angeles");
using var cmd = connection.CreateCommand();
cmd.CommandText = "INSERT INTO tz_test (tz_value) VALUES (:1)";
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
However, it seems impossible to replicate this functionality using Oracle EF Provider. If I create an entity and add a property of type OracleTimestampWithTimezone
, I get an exception:
'The property 'TzTest.TzValue' could not be mapped because it is of type 'OracleTimeStampTZ', which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.'
Could you please add support to Oracle EF Core Provider for OracleTimestampWithTimezone
? My goal is to store a value in TIMESTAMP WITH TIME ZONE
in TZR TZD format without data loss, is there any way to achieve this with Oracle EF Core?
Thank you.
For reference, I am already discussing this in EF Core repository, but so far it looks like this is something Oracle needs to add support for.