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

                 Key: DNET-855
                 URL: http://tracker.firebirdsql.org/browse/DNET-855
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 6.3.0.0
         Environment: .NET framework 4.6.1, VS 2017
            Reporter: robsonwk
            Assignee: Jiri Cincura


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;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to