Page 1 of 1

Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Wed 08 Sep 2021 07:09
by PeterUser
Good morning,

I am using Devart.Data.Oracle.EF6 9.14.1273 with EntityFramework 6.4.4 and see an annoying bug with sql script generation:

When I run

Code: Select all

Update-Database -Verbose -ProjectName MyProject  -ConnectionString "xxx" -ConnectionProviderName "Devart.Data.Oracle" -Script
I receive a .sql file like

Code: Select all

ALTER TABLE USER.BOX_VERSIONS
MODIFY CREATION_DATE TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL

/

DECLARE


instead of the expected

Code: Select all

ALTER TABLE USER.BOX_VERSIONS
MODIFY CREATION_DATE TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL
  EXECUTE IMMEDIATE 'ALTER TABLE USER.BOX_VERSIONS MODIFY CREATION_DATE NOT NULL';
EXCEPTION
  WHEN OTHERS THEN
    IF SQLCODE <> -1451 AND SQLCODE <> -1442 THEN
      RAISE;
    END IF;
END;
/

DECLARE
  BINARY_VALUE BLOB;
BEGIN
  DBMS_LOB.CREATETEMPORARY(BINARY_VALUE, TRUE);
  DBMS_LOB.APPEND(BINARY_VALUE, TO_BLOB(CAST('...' AS LONG RAW)));
  INSERT INTO USER."__MigrationHistory" ("MigrationId", "ContextKey", "Model", "ProductVersion") VALUES ('202109080628292_Test', 'Qm.Tda.Dal.Migrations.Configuration', BINARY_VALUE, '6.4.4');
END;

the missing code ends up in the Visual Studio Package Management Console. It seems like for some multiline statements only the first line is written to the file. This is especially annoying, if I have multiple of those statements in one migration, since I have to manually reorder them.

The problem occurs with both .Net Framework 4.8 and .Net 5.

Is there a way to circumvent this?

Kind regards
Peter

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Wed 08 Sep 2021 15:34
by Shalex
Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Thu 09 Sep 2021 07:05
by PeterUser
Great. Thanks a lot.

It's no blocking issue, but quite inconvenient.

Have a nice day
Peter

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Thu 28 Oct 2021 15:18
by Shalex
The bug with incomplete SQL generation by update-database -script in Entity Framework 6.4.4 is fixed. We will notify you when a new public build of dotConnect for Oracle is available for download.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Tue 09 Nov 2021 16:41
by Shalex
New build of dotConnect for Oracle 9.14.1382 is available for download now: viewtopic.php?f=1&t=50114.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Thu 11 Nov 2021 10:39
by PeterUser
Hello Alex,

thanks for the reply.

But I think it is still not completely fixed. When I create the script for my test, I get this in the .sql file:

Code: Select all

-- Script was generated by Devart dotConnect for Oracle, Version 9.14.1382
-- Product home page: http://www.devart.com/dotconnect/oracle
-- Database version: Oracle 12.1.0.2
-- Script date 11.11.2021 11:33:30

BEGIN
/

CREATE UNIQUE INDEX UT_ARIANE.IX_1390940320 ON UT_ARIANE.BOX_LOTS (BOX_ID, BOX_VERSION_NO, LABEL)
/

DECLARE
  BINARY_VALUE BLOB;
BEGIN
  DBMS_LOB.CREATETEMPORARY(BINARY_VALUE, TRUE);
  .
  .
  .
  INSERT INTO UT_ARIANE."__MigrationHistory" ("MigrationId", "ContextKey", "Model", "ProductVersion") VALUES ('202111111031023_Test', 'Tests.Migrations.Configuration', BINARY_VALUE, '6.4.4');
END;
/



The output on the Visual Studio Package Management Console contains the rest:

Code: Select all

Applying explicit migrations: [202111111031023_Test].
Applying explicit migration: 202111111031023_Test.
  FOR c IN (
    SELECT INDEX_OWNER, INDEX_NAME
      FROM SYS.ALL_IND_COLUMNS
    WHERE TABLE_OWNER = 'UT_ARIANE' AND TABLE_NAME = 'BOX_LOTS' AND COLUMN_NAME IN ('BOX_ID', 'BOX_VERSION_NO', 'ID')
    HAVING COUNT(*) = 3
    GROUP BY INDEX_OWNER, INDEX_NAME
  )
  LOOP
    SYS.DBMS_UTILITY.EXEC_DDL_STATEMENT(
      'DROP INDEX "' || c.INDEX_OWNER || '"."' || c.INDEX_NAME || '"'
    );
  END LOOP;
END;

It seems to me, that the fix only applies to the MigrationHistory part, but not to other multiline SQL commands, at least not to the new drop-by-name script.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Fri 12 Nov 2021 17:42
by Shalex
Thank you for the additional information. We have reproduced the script generation issue with "config.CodeFirstOptions.DropConstraintsByColumns=true;" and will notify you when it is fixed.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Wed 01 Dec 2021 14:54
by Shalex
The bug with incomplete SQL generation by update-database -script when config.CodeFirstOptions.DropConstraintsByColumns=true in Entity Framework 6.4.4 is fixed. We will notify you when a new public build of dotConnect for Oracle is available for download.

Re: Script generation broken for EF 6.4.4 with dotconnect for Oracle

Posted: Tue 21 Dec 2021 17:42
by Shalex
dotConnect for Oracle 9.15 is released: viewtopic.php?f=1&t=51634.