Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

DateTimeOffset could not be mapped to the database type 'TIMESTAMP(6) WITH LOCAL TIME ZONE'

user-didq2May 19 2023

Hi - I have used EF Core Power Tools to scaffold some tables. It generates like this for all my TIMESTAMP(6) WITH LOCAL TIME ZONE columns:

[Column(TypeName = "TIMESTAMP(6) WITH LOCAL TIME ZONE")]
public DateTimeOffset CREATED_DATE_TIME { get; set; }
and

entity.Property(e => e.CREATED_DATE_TIME)
.ValueGeneratedOnAdd()
.HasDefaultValueSql("LOCALTIMESTAMP ");

When I query the table I get:

System.InvalidOperationException: 'The 'DateTimeOffset' property 'GLD_SESSIONS.CREATED_DATE_TIME' could not be mapped to the database type 'TIMESTAMP(6) WITH LOCAL TIME ZONE' because the database provider does not support mapping 'DateTimeOffset' properties to 'TIMESTAMP(6) WITH LOCAL TIME ZONE' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.'

It seems from my googling that this should work. Any advice?

Versions of stuff:

Oracle RDBMS: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0

Comments
Post Details
Added on May 19 2023
5 comments
947 views