- 3,716,003 Users
- 2,242,928 Discussions
- 7,845,734 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 476 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 5 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 417 SQLcl
- 42 SQL Developer Data Modeler
- 184.9K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 9 DevOps
- 3K QA/Testing
- 256 Java
- 6 Java Learning Subscription
- 10 Database Connectivity
- 67 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 11 Español
- 1.9K Japanese
- 2 Portuguese
Works with Oracle.EntityFrameWorkCore beta 2 but broken with beta 3 - OracleRelationalCommand.Create

For a new application, we are using ASP.NET Core 2.2 Identity with the schema created in Oracle. We let the Oracle provider create a migration for the Identity tables and then generated a script from the migration. It has been working great with the Oracle EF Provider beta 2. However, with beta 3, there is an exception when the Identity framework tries to write a value to the LockoutEnd field. It fails with the error shown below. The datatype for the LockoutEnd field is TIMESTAMP (3) WITH TIME ZONE and the .NET datatype is DateTimeWithOffset. As mentioned, this works fine with the beta 2 release. Since this works in beta 2 I don't want to spend time looking for a work around in case this will work again in a future release.
Here is the mapping that is being used for the LockoutEnd field:
LockoutEnd (Nullable<DateTimeOffset>) 6 6 -1 -1 -1
Annotations:
Relational:TypeMapping: Oracle.EntityFrameworkCore.Storage.Internal.OracleDateTimeOffsetTypeMapping
Error during update:
OracleRelationalCommand.CreateCommand() : System.ArgumentException: Value does not fall within the expected range.
at Oracle.ManagedDataAccess.Client.OracleParameter.set_Value(Object value)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping.CreateParameter(DbCommand command, String name, Object value, Nullable`1 nullable)
at Microsoft.EntityFrameworkCore.Storage.Internal.TypeMappedRelationalParameter.AddDbParameter(DbCommand command, Object value)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalParameterBase.AddDbParameter(DbCommand command, IReadOnlyDictionary`2 parameterValues)
at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.CreateCommand(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
ERROR: An exception occurred in the database while saving changes for context type 'Wake.LandRecords.Ptms.Services.Identity.Infrastructure.Data.ApplicationDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.ArgumentException: Value does not fall within the expected range.
at Oracle.ManagedDataAccess.Client.OracleParameter.set_Value(Object value)
Best Answer
-
We plan to fix DateTimeOffset in Beta 4. I don't know if it will solve your specific use case, but be sure to try it out and let us know when we release the next beta.
Answers
-
There are known issues with using with using DateTimeOffset with the Oracle EF Core Beta. These are noted in both the Beta 2 and Beta 3 doc. Oracle is working on resolving these issues by production.
-
I see it in the docs now. Thanks!
-
We plan to fix DateTimeOffset in Beta 4. I don't know if it will solve your specific use case, but be sure to try it out and let us know when we release the next beta.
-
I've found a trick in order to solve this issue.
The idea is to map DateTimeOffset inside HashTable of OracleParameter.
This trick is not a good practice because it modify a private variable and in future this fix could be not working as expected so use it at your risk.
I copy a piece of code that describe idea:
var assembly = typeof(OracleCommand).Assembly;
var allAssemblyTypes = assembly.GetTypes();
var oracleDbTypeTableType = allAssemblyTypes.Where(t => t.Name == "OraDb_DbTypeTable").First();
var hashTableFieldInfo = oracleDbTypeTableType.GetField("s_table", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
var hashTableOfMappingTypes = (Hashtable)hashTableFieldInfo.GetValue(null);
hashTableOfMappingTypes.Add(typeof(DateTimeOffset), OracleDbType.TimeStamp);
Regards,
Sandro