Page 1 of 1

Code first migration from NVARCHAR2 to NCLOB failed

Posted: Fri 25 Sep 2015 18:26
by John Liu
Using EF 6.1.3 and dotConnect for oracle 8.4.359 in a Code first migration, I tried to convert a data field from NVARCHAR2 to NVARCHAR(max) in SQL server and everything worked fine. But the same migration failed with an Oracle database.

Fluent maping was
this.Property(t => t.Element).HasMaxLength(256);
Changed to
this.Property(t => t.Element).IsMaxLength();

PM console commends
- Add-Migration V1
AlterColumn("A.PREFERENCE", "ELEMENT", c => c.String());

Update-Database -targetmigration V1
System.NotSupportedException: ORA-22859: invalid modification of columns. An attempt was made to modify NCLOB column type.


thanks
JL

Re: Code first migration from NVARCHAR2 to NCLOB failed

Posted: Thu 01 Oct 2015 11:59
by Shalex
That is a limitation of Oracle: it doesn't allow to change datatype of the column from VARCHAR2 to NCLOB.

Try to implement the following workaround:
1. Add the new column.
2. Copy data from the Element column to the new column via SqlOperation.
3. Remove the Element column.
4. Rename the new column to "Element".