Script generation broken for EF 6.4.4 with dotconnect for Oracle

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Script generation broken for EF 6.4.4 with dotconnect for Oracle

Post by PeterUser » Wed 08 Sep 2021 07:09

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

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

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

Post by Shalex » Wed 08 Sep 2021 15:34

Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

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

Post by PeterUser » Thu 09 Sep 2021 07:05

Great. Thanks a lot.

It's no blocking issue, but quite inconvenient.

Have a nice day
Peter

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

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

Post by Shalex » Thu 28 Oct 2021 15:18

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.

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

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

Post by Shalex » Tue 09 Nov 2021 16:41

New build of dotConnect for Oracle 9.14.1382 is available for download now: viewtopic.php?f=1&t=50114.

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

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

Post by PeterUser » Thu 11 Nov 2021 10:39

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.

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

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

Post by Shalex » Fri 12 Nov 2021 17:42

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.

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

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

Post by Shalex » Wed 01 Dec 2021 14:54

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.

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

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

Post by Shalex » Tue 21 Dec 2021 17:42

dotConnect for Oracle 9.15 is released: viewtopic.php?f=1&t=51634.

Post Reply