oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

Unable to change NVARCHAR2 to CLOB with no warning #382

Closed plachta11b closed 1 month ago

plachta11b commented 1 month ago

Expected EF to convert the column from NVARCHAR2(4000) to CLOB or to throw some error. Migration succeded without column change.

I found out that conversion with LONG as the middle step should work (https://github.com/oracle/dotnet-db-samples/issues/262), but I have got the error below when converting from LONG to CLOB:

Unhandled exception. Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-22858: invalid alteration of datatype ORA-06512

Workaround used:

migrationBuilder.Sql(@"ALTER TABLE SCHEMA.TABLE ADD (COLLUMN_CLOB CLOB)");
migrationBuilder.Sql(@"UPDATE SCHEMA.TABLE SET COLLUMN_CLOB = COLLUMN_NAME");
migrationBuilder.Sql(@"COMMIT");
migrationBuilder.Sql(@"ALTER TABLE SCHEMA.TABLE RENAME COLUMN COLLUMN_NAME TO COLLUMN_VARCHAR");
migrationBuilder.Sql(@"ALTER TABLE SCHEMA.TABLE RENAME COLUMN COLLUMN_CLOB TO COLLUMN_NAME");
migrationBuilder.Sql(@"COMMIT");
migrationBuilder.Sql(@"ALTER TABLE SCHEMA.TABLE DROP COLUMN COLLUMN_VARCHAR;");
alexkeh commented 1 month ago

@plachta11b Do you have a complete test case we can use to reproduce the problem? Which versions of Oracle DB, EF Core, and ODP.NET EF Core are you using?

alexkeh commented 1 month ago

Closing for now. Will reopen once we get more info to identify more use case details and versions used.