Showstopper: OracleLoader and identity columns
Posted: Mon 05 May 2014 11:16
We've just ran into a problem using OracleLoader with Oracle 12c database generated with EF's ObjectContext.CreateDatabase/Script(). Our scenario is to copy a table containing an identity column from one database (arbitrary DMS, e.g. Oracle, SQL Server, etc.) to the other (Oracle). The problem is that the source table has already all its values assigned, including those for the identity column. This works perfectly on Oracle 11g but fails on Oracle 12c with the error "ORA-32795: cannot insert into a generated always identity column", because the identity column is defined as GENERATED ALWAYS. Ignoring identity columns in application logic is not an option since it would require too much efforts, especially for complicated foreign key fix-up.
Note that SqlClient.SqlBulkCopy class does already support this scenario out-of-the-box by providing the "KeepIdentity" option.
We believe the problem could be easily solved by defining identity columns as GENERATED BY DEFAULT in ObjectContext.CreateDatabase/Script() or at least make such an option available via provider settings.
Note that SqlClient.SqlBulkCopy class does already support this scenario out-of-the-box by providing the "KeepIdentity" option.
We believe the problem could be easily solved by defining identity columns as GENERATED BY DEFAULT in ObjectContext.CreateDatabase/Script() or at least make such an option available via provider settings.