- 3,715,654 Users
- 2,242,820 Discussions
- 7,845,479 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 467 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 247 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 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
- 10 Español
- 1.9K Japanese
- 2 Portuguese
Oracle.EntitiyFramewokCore ENUM Conversion Problem
Hello,
We are migrating our project to .net core and are using Oracle.EntitiyFramewokCore to connect to Oracle DB. But we have a problem with ENUM types. Please see below for more detail.
ERROR: Microsoft.EntityFrameworkCore.DbUpdateException: 'An error occurred while updating the entries. See the inner exception for details.'
Inner Exception: ArgumentException: Value does not fall within the expected range.
public class SystemConfirmation
{
public long Id { get; set; }
public long? ObjectId { get; set; }
public SystemConfirmationStatus Status { get; set; }
public ObjectType Type { get; set; }
public byte[] Data { get; set; }
public string DataType { get; set; }
public long CompanyId { get; set; }
public ConfirmationActionTypes ActionType { get; set; }
public DateTime? InsertDatetime { get; set; }
public DateTime? SysLastUpdate { get; set; }
public int? SysVersion { get; set; }
}
Mapper:
builder.ToTable("FIN_SYSTEM_CONFIRMATION", "EFINUSER");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("ID").HasColumnType("NUMBER(12)");
builder.Property(x => x.ObjectId).HasColumnName("OBJECT_ID").HasColumnType("NUMBER(12)");
builder.Property(x => x.Status).HasColumnName("STATUS").HasColumnType("NUMBER(10)");
builder.Property(x => x.Type).HasColumnName("TYPE").HasColumnType("NUMBER(10)");
builder.Property(x => x.Data).HasColumnName("DATA").HasColumnType("BLOB");
builder.Property(x => x.DataType).HasColumnName("DATA_TYPE").HasColumnType("VARCHAR2").HasMaxLength(1000);
builder.Property(x => x.CompanyId).HasColumnName("COMPANY_ID").HasColumnType("NUMBER(12)").HasMaxLength(10);
builder.Property(x => x.ActionType).HasColumnName("ACTION_TYPE").HasColumnType("NUMBER(10)");
builder.Property(x => x.SysVersion).HasColumnName("SYS_VERSION").HasColumnType("NUMBER(10)");
builder.Property(x => x.SysLastUpdate).HasColumnName("SYS_LAST_UPDATE").HasColumnType("DATE");
builder.Property(x => x.InsertDatetime).HasColumnName("INSERT_DATETIME").HasColumnType("DATE");
Answers
-
Apologies if this is completely off base as I don't use entity framework, but...
builder.Property(x => x.CompanyId).HasColumnName("COMPANY_ID").HasColumnType("NUMBER(12)").HasMaxLength(10);
What does it mean to specify HasMaxLength() for a number column? Is that possibly the cause of the issue you are seeing? It just seems odd to me but may be perfectly reasonable in the entity framework world.
Regards,
Mark
-
Enums are supported by ODP.NET EF Core. It's unclear what the error cause is with the level of detail given. Here's more info on how to use enums with EF Core:
https://docs.microsoft.com/en-us/ef/core/modeling/value-conversions