EF 6 RC1 Default values for not null fields

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

EF 6 RC1 Default values for not null fields

Post by John Liu » Thu 10 Oct 2013 17:41

Hi,
Sql server provider provides default values for not null fields (bool-0, int - 0, decimal-0) automatically. dotConnect for oracle doesn't following the same convention. I got the follwoing errors because of that (no problem with sql server). I know a way to fix that in my application. But it's better if dotConnect for oracle can follow the same convention as the sql server provider.
thanks
JL

ALTER TABLE AZ.PWCODE
ADD ISACTIVE NUMBER(1) NOT NULL
Devart.Data.Oracle.OracleException (0x80004005): ORA-01758: table must be empty to add mandatory (NOT NULL) column
at Devart.Data.Oracle.b4.d()
at Devart.Data.Oracle.cf.f()
at Devart.Data.Oracle.cf.c()
at Devart.Data.Oracle.i.a(Int32 A_0, cc A_1)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass32.<ExecuteStatements>b__2e()
at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument 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.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.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.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.Design.ToolingFacade.UpdateRunner.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.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ORA-01758: table must be empty to add mandatory (NOT NULL) column

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

Re: EF 6 RC1 Default values for not null fields

Post by Shalex » Mon 14 Oct 2013 12:52

John Liu wrote:Sql server provider provides default values for not null fields (bool-0, int - 0, decimal-0) automatically.
... it's better if dotConnect for oracle can follow the same convention as the sql server provider.
Thank you for your suggestion. We will notify you when the corresponding functionality is implemented in dotConnect for Oracle.

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

Re: EF 6 RC1 Default values for not null fields

Post by Shalex » Tue 15 Oct 2013 12:18

The behaviour will be changed starting from the next public build of dotConnect for Oracle: when adding new NOT NULL columns in the existing table, Code-First Migrations will generate
  • DEFAULT 0 for the columns of numeric types
  • DEFAULT EMPTY_CLOB() for the columns of CLOB/NCLOB types
  • DEFAULT '' for the columns of CHAR/NCHAR/VARCHAR2/NVARCHAR2 types
We will post here when the new build of dotConnect for Oracle is available for download.

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

Re: EF 6 RC1 Default values for not null fields

Post by Shalex » Fri 18 Oct 2013 11:05

New version of dotConnect for Oracle 8.0 is released!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=28131.

Post Reply