Error when using latest Oracle.EntityFrameworkCore 9 with CLOB column
tegrit-joe-trupiano opened this issue · 9 comments
"Content" property in image is a ColumnType of CLOB set in DBContext.
First line crashes in the image. Second line works. First line worked in .net8
Stack Trace
at Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlConstantExpression..ctor(Object value, RelationalTypeMapping typeMapping) at Microsoft.EntityFrameworkCore.Query.SqlExpressionFactory.Constant(Object value, RelationalTypeMapping typeMapping) at Oracle.EntityFrameworkCore.Query.Internal.OracleSqlTranslatingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression) at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.TranslateInternal(Expression expression, Boolean applyDefaultTypeMapping) at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression, Boolean applyDefaultTypeMapping) at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateExpression(Expression expression, Boolean applyDefaultTypeMapping) at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateLambdaExpression(ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression) at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate) at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression) at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_01.b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1.GetEnumerator()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
@tegrit-joe-trupiano Can you turn on ODP.NET tracing and share the trace? We can then see the specific Oracle exception that occurs and the generated SQL.
@alexkeh the query in question does not create a trace as it crashes in Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlConstantExpression. I moved the query that works and ran tracing for that and attached it.
here is a picture of my test code

trace.EXE_PID_11424_DATE_2025_01_03_TIME_16_23_57_482451.txt
EDIT:
Looks like it crashes because it calls this line because "value" is null
efcore
SqlConstantExpression class changed a lot between .net8 and .net9
@tegrit-joe-trupiano I don't see any error or crash in the trace. We will need to increase the TraceLevel to capture more detailed diagnostics. Please use TraceLevel=7. It will capture private ODP.NET APIs, data, and network traffic.
Trace level 7 for the code below included two files.
using (var scope = app.Services.CreateScope())
{
var service = scope.ServiceProvider;
var context = service.GetService<ArrivosBaseDbContext>();
OracleConfiguration.TraceFileLocation = @"C:\traces";
OracleConfiguration.TraceLevel = 7;
//Works
var list2 = context.HelpContent.Where(i => !string.IsNullOrWhiteSpace(i.Content)).ToList();
//trace stops here
//Crashes
var list = context.HelpContent.Where(i => i.Content != null).ToList();
}
ARRIVOS3.PENSIONADMIN.EXE_PID_15664_DATE_2025_01_06_TIME_11_38_24_419224.txt
ARRIVOS3.PENSIONADMIN.EXE_PID_15664_DATE_2025_01_06_TIME_11_38_24_693947.txt
@tegrit-joe-trupiano Something odd is going on with the generated traces. The two files appear to capture the traces back to back. The first trace file is generated at level 7. The second one is generated at trace level 1. At the end of the first trace file, I see:
2025-01-06 11:38:24.693461 TID:1 (PUB) (OCFG) OracleConfiguration.TraceFileLocation() trying to change from C:\traces to C:\traces
2025-01-06 11:38:24.693482 TID:1 (PUB) (OCFG) OracleConfiguration.TraceLevel() trying to change from 0 to 1
Then, the second trace file at level 1 begins right after the first one ends. I'm guessing the crash occurs at the end of the second trace file, which doesn't have the detail that level 7 provides.
Are you inadvertently setting the TraceLevel to 1 somewhere else in your code?
@alexkeh Yes good catch, sorry about that here is the proper log all at level 7
ARRIVOS3.PENSIONADMIN.EXE_PID_40884_DATE_2025_01_06_TIME_13_00_13_636703.txt
@tegrit-joe-trupiano There's no ODP.NET error in the trace. The problem coud be something ODP.NET is passing back to EF Core or an issue with EF Core 9 itself. I have asked one of my ODP.NET dev team members to review the trace for more analysis.
I've created bug 37459153 to track this issue.
@alexkeh Let me know if you need anything else from me!

