Hi,
I'm encountering a critical issue when using Entity Framework Core together with Oracle.ManagedDataAccess.OpenTelemetry
and Oracle sequences.
Scenario
I'm using EF Core to insert data into a table where the primary key is generated from a sequence. The model is configured using the UseSequence()
API to instruct EF Core to use the Oracle sequence, like so:
modelBuilder.Entity<MyEntity>()
.Property(e => e.Id)
.HasColumnName("ID")
.ValueGeneratedOnAdd()
.UseSequence("MY_SEQ");
//OR
modelBuilder.Entity<MyEntity>()
.Property(e => e.Id)
.HasColumnName("ID")
.ValueGeneratedOnAdd()
.HasDefaultValueSql("MY_SEQ.NEXTVAL");
Separately, I'm also instrumenting database calls using Oracle.ManagedDataAccess.OpenTelemetry
. When I enable SQL ID tracing like this:
OracleConfiguration.OpenTelemetry.EnableSqlIdTracing = true;
//OR with DI
builder.Services.AddOpenTelemetry().WithTracing(tracing =>
{
tracing.AddOracleDataProviderInstrumentation(opts =>
{
opts.EnableSqlIdTracing = true;
});
});
and try to perform an insert using EF Core, the application fails and the Oracle client throws this exception: OracleException: ORA-12537: TNS:connection closed
Observations
- The error only occurs when all three conditions are met:
- EF Core uses
UseSequence()
with default value as SEQ.NEXTVAL
Oracle.ManagedDataAccess.OpenTelemetry
is being used
EnableSqlIdTracing = true
- If I disable SQL ID tracing, the insert works as expected.
- If I don’t use sequences, or insert manually using raw SQL, it also works fine even with SQL ID tracing enabled.
Environment
- Oracle.ManagedDataAccess.Core version: 23.8.0
- Oracle.EntityFrameworkCore version: 8.23.60
- Oracle.ManagedDataAccess.OpenTelemetry version: 23.8.0
- EF Core version: 8.0.3
- .NET version: 8