Code first migration from NVARCHAR2 to NCLOB failed

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
John Liu
Posts: 61
Joined: Wed 14 Nov 2012 20:58

Code first migration from NVARCHAR2 to NCLOB failed

Post by John Liu » Fri 25 Sep 2015 18:26

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

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

Re: Code first migration from NVARCHAR2 to NCLOB failed

Post by Shalex » Thu 01 Oct 2015 11:59

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".

Post Reply