Code First created names too long with Orcl 12c R2

Code First created names too long with Orcl 12c R2

Postby Globox » Fri 14 Jul 2017 10:30

Hello!

I have some trouble using code first migrations to an Oracle 12c R2 server with Devart. When running 'update-database', it throws an System.InvalidOperationException stating: "Foreign key name 'FK_WithTooLongNameAndItGivesAnError_US' in table "MyTable" is too long (38 characters). An identifier with more than 30 characters was specified.".

I am familiar with Oracle's identifier length limit of 30 bytes, however in Oracle 12c R2 the limit was raised to 128 bytes. Using SQL Plus I can create columns with names way longer than 30 characters without a problem. The error is given by Devart, not the database.

I am using EF6, and the latest Devart version (2017-July-13).

The exception call stack is below:
Code: Select all
at Devart.Common.Entity.c9.a(String A_0, String A_1, String A_2, Int32 A_3)
   at Devart.Common.Entity.c9.b(String A_0, String A_1)
   at Devart.Common.Entity.c9.a(eg A_0, String A_1)
   at Devart.Common.Entity.c9.a(z A_0)
   at Devart.Common.Entity.z.a(m A_0)
   at Devart.Common.Entity.Migrations.c.a(IEnumerable`1 A_0)
   at Devart.Common.Entity.Migrations.d.a(IEnumerable`1 A_0, er A_1)
   at Devart.Data.Oracle.Entity.Migrations.OracleEntityMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
   at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
   at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
   at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Globox
 
Posts: 4
Joined: Fri 14 Jul 2017 10:04

Re: Code First created names too long with Orcl 12c R2

Postby Shalex » Tue 18 Jul 2017 09:41

Globox wrote:"Foreign key name 'FK_WithTooLongNameAndItGivesAnError_US' in table "MyTable" is too long (38 characters). An identifier with more than 30 characters was specified."
Please fix the issue using the TruncateLongDefaultNames option like described at http://forums.devart.com/viewtopic.php?t=34597#p119958.

Globox wrote:in Oracle 12c R2 the limit was raised to 128 bytes
We will investigate the possibility to take into account this change when generating SQL and notify you about the result.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44

Re: Code First created names too long with Orcl 12c R2

Postby Globox » Tue 18 Jul 2017 14:56

Thank you for your reply!

I know about the TruncateLongDefaultNames options, in fact, I have already tried it (and it works in general), however it won't work for us, as we need the original, unmodified name of the identifiers.

Looking forward for your investigation in 12cR2!
Globox
 
Posts: 4
Joined: Fri 14 Jul 2017 10:04

Re: Code First created names too long with Orcl 12c R2

Postby Shalex » Fri 04 Aug 2017 17:38

The possibility to create database objects with names up to 128 characters long in Oracle 12c Release 2 is supported: http://forums.devart.com/viewtopic.php?f=1&t=35777.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44

Re: Code First created names too long with Orcl 12c R2

Postby Globox » Tue 08 Aug 2017 11:30

Awesome! Will check, thank you!
Globox
 
Posts: 4
Joined: Fri 14 Jul 2017 10:04


Return to dotConnect for Oracle