Devart.Data.Oracle.EFCore v9.15.1410 'ORA-00911: invalid character' when using transaction
Posted: 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:
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)
Just execute the command Add-Migration and run the application.
This issue is blocking the update of my company framework to net6.0.
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)
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; }
}
This issue is blocking the update of my company framework to net6.0.