Issue Details (XML | Word | Printable)

Key: DNET-855
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Jiri Cincura
Reporter: robsonwk
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

DbMigration.CreateTable creates shared sequence (generator) for any identity column

Created: 21/Oct/18 09:25 PM   Updated: 23/Oct/18 06:40 AM
Component/s: Entity Framework
Affects Version/s: 6.3.0.0
Fix Version/s: None

Environment: .NET framework 4.6.1, VS 2017


 Description  « Hide
Using DbMigration, method CreateTable with column Identity set to true, generates one, common sequence for any table, any column.
Result sql code is as following:

  EXECUTE BLOCK
            AS
            BEGIN
if (not exists(select 1 from rdb$generators where rdb$generator_name = 'GEN_IDENTITY')) then
begin
execute statement 'create sequence GEN_IDENTITY';
end
            END;

and trigger

CREATE OR ALTER TRIGGER "ID_USERS_ID" ACTIVE BEFORE INSERT ON "USERS"
                  AS
                    BEGIN

                  if (new."ID" is null) then
                    begin

                  new."ID" = next value for GEN_IDENTITY;
                  end
                  END;

Proposal:
For table "Users", column "ID", migration sql could be:
  EXECUTE BLOCK
            AS
            BEGIN
if (not exists(select 1 from rdb$generators where rdb$generator_name = 'GEN_IDENTITY_USERS_ID')) then
begin
execute statement 'create sequence GEN_IDENTITY_USERS_ID';
end
            END;

and trigger

CREATE OR ALTER TRIGGER "ID_USERS_ID" ACTIVE BEFORE INSERT ON "USERS"
                  AS
                    BEGIN

                  if (new."ID" is null) then
                    begin

                  new."ID" = next value for GEN_IDENTITY_USERS_ID;
                  end
                  END;

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jiri Cincura added a comment - 22/Oct/18 08:22 AM
This is intentional. If you want different behavior, implement IFbMigrationSqlGeneratorBehavior.

robsonwk added a comment - 22/Oct/18 08:31 PM
Ok, thank you for such quick response, however could you in a few words give exaplanation of a such design?