Closed anoordover closed 1 year ago
Thanks for reporting. I've reproduced the problem with the duplicative alias and filed bug 35325121 to have the root cause investigated further.
After further investigation, this is a generic EF Core issue that is also replicable with the EF Core SQL Server provider. A Github bug is filed for this testcase, which MS has currently scheduled to fix by EF 8.0.0 (November 2023). https://github.com/dotnet/efcore/issues/30856
I execute an ExecuteUpdate in Oracle EF Core (I don't know if this is an Oracle EF Core or EF Core issue). When the Linq statement uses two tables have the same first letter in the table-name the same alias is being reused. eg (when the table-name are XYZ_CREDITS and XYZ_DECLARATIONS):
var r = db.Credits.Where(c => c.Id == 1) .Select(c => new { credit = c, declaration = db.Declarations .First(d => d.Reference == c.ReferenceDeclaration) }) .ExecuteUpdate(calls => calls.SetProperty( c => c.credit.DeclarationId, c => c.declaration.Id)); the SQL begin generated seems to be:
UPDATE "XYZ_CREDITS" "x" SET "x"."DeclarationId" = ( SELECT "x"."Id" FROM "XYZ_DECLARATIONS" "x" WHERE "x"."Reference" = ""."ReferenceDeclaration" FETCH FIRST 1 ROWS ONLY) WHERE "x"."Id" = 1
See https://github.com/anoordover/OracleDbDemo In the repo I mention 3 issues. This issue is only about the re-use of the same alias.