Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
jamir.araujo
Posts: 22
Joined: Wed 13 Mar 2019 17:25

Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Post by jamir.araujo » Mon 03 Jan 2022 19:57

Hi, I'm using the package Devart.Data.Oracle.EFCore v9.15.1410 and I'm facing the following database error when calling DbContext.SaveChangesAsync() with an active transaction ORA-00911: invalid character.

Here is the callstack:

Code: Select all

Unhandled exception. Devart.Data.Oracle.OracleException (0x80004005): ORA-00911: invalid character
   at Devart.Data.Oracle.dr.a(ay A_0, Int32 A_1)
   at Devart.Data.Oracle.dr.e5(Int32 A_0, bx A_1)
   at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
   at Devart.Common.Entity.cs.ExecuteNonQuery()
   at Devart.Data.Oracle.Entity.ao.ExecuteNonQuery()
   at System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
By looking the callstack and digging through EFCore code, it seems to be the transaction savepoint feature that is causing the issue. Probably the RelationalSqlGenerationHelper is generating an invalid command.

You can reproduce the issue with the following code (in the new net6.0 console template)

Code: Select all

using Microsoft.EntityFrameworkCore;

Console.WriteLine("Starting...");

var context = new ProductDbContext();

context.Database.AutoSavepointsEnabled = false;
await context.Database.MigrateAsync();

var transaction = await context.Database.BeginTransactionAsync();

context.Products?.Add(new Product());

await context.SaveChangesAsync();
await transaction.CommitAsync();

Console.WriteLine("End.");


class ProductDbContext : DbContext
{
    public DbSet<Product>? Products { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        base.OnConfiguring(optionsBuilder);

        optionsBuilder.UseOracle("host=127.0.0.1;port=1521;sid=xe;direct=true;uid=ORACLE_BUG;pwd=ORACLE_BUG;license key=...");
    }
}

public class Product
{
    public int Id { get; set; }
    public string? Name { get; set; }
}
Just execute the command Add-Migration and run the application.

This issue is blocking the update of my company framework to net6.0.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Post by Shalex » Tue 04 Jan 2022 16:44

The bug with auto savepoints enabled in EF Core 6 transactions is fixed. We will notify you when a new public build of dotConnect for Oracle is available for download.

The internal build with the fix can be downloaded from http://download.devart.com/nuget_oracle_9_15_1419.zip.

FluxZwo
Posts: 1
Joined: Tue 18 Jan 2022 12:41

Re: Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Post by FluxZwo » Mon 24 Jan 2022 07:53

This fix would help us - is there an timeframe when this version comes to nuget.org?

Thanks and greetings

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Post by Shalex » Mon 24 Jan 2022 11:03

We are going to release a new public build this week.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction

Post by Shalex » Thu 27 Jan 2022 16:12

dotConnect for Oracle 9.16 is released: viewtopic.php?f=1&t=53190.

Post Reply