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!

Bug: ORA-12537 when using EF Core + UseSequence + Oracle.ManagedDataAccess.OpenTelemetry with SQL ID tracing enabled

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:
    1. EF Core uses UseSequence() with default value as SEQ.NEXTVAL
    2. Oracle.ManagedDataAccess.OpenTelemetry is being used
    3. 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
This post has been answered by Alex Keh-Oracle on Jul 22 2025
Jump to Answer
Comments
Post Details
Added on Jun 27 2025
6 comments
288 views