Bug found: Guid primary key, always change?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Bug found: Guid primary key, always change?

Post by RobertK » Tue 06 Jun 2017 05:06

Entity Developer: 6.1.2.265

=========================
Create a class/table with a few columns and a primary key with the following settings

Code: Select all

Nullable: unchecked
Primary: checked
--

Code: Select all

Name: Id
Type: Guid
Value Generated: OnAdd
Primary Key: checked
Shadow: Unchecked
Column: id
Proceed with "Update database from model", success!
Now try that again "Update database from model", the application will indicate that the primary key has been changed but it has not been changed.

RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Re: Bug found: Guid primary key, always change?

Post by RobertK » Tue 06 Jun 2017 05:13

If you like to test this with ASP.NET Core Identity with Postgres using GUID primary keys, execute the sql query below, then update model from database then change User primary key to value generated to "OnAdd", finally update database from model.

Update database from model do this twice so you can see "Id" primary key will always indicate it has been changed.

Code: Select all

/*
Database type: Postgres
Description: Standard ASP.NET Core Identity framework tables using GUID primary key datatype
*/


-- ----------------------------
-- Sequence structure for role_claim_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "role_claim_id_seq";
CREATE SEQUENCE "role_claim_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for user_claim_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "user_claim_id_seq";
CREATE SEQUENCE "user_claim_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS "role";
CREATE TABLE "role" (
"id" uuid NOT NULL,
"concurrency_stamp" text COLLATE "default",
"name" varchar(256) COLLATE "default",
"normalized_name" varchar(256) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of role
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for role_claim
-- ----------------------------
DROP TABLE IF EXISTS "role_claim";
CREATE TABLE "role_claim" (
"id" int4 DEFAULT nextval('role_claim_id_seq'::regclass) NOT NULL,
"claim_type" text COLLATE "default",
"claim_value" text COLLATE "default",
"role_id" uuid NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of role_claim
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS "user";
CREATE TABLE "user" (
"id" uuid NOT NULL,
"access_failed_count" int4 NOT NULL,
"concurrency_stamp" text COLLATE "default",
"email" varchar(256) COLLATE "default",
"email_confirmed" bool NOT NULL,
"lockout_enabled" bool NOT NULL,
"lockout_end" timestamptz(6),
"normalized_email" varchar(256) COLLATE "default",
"normalized_user_name" varchar(256) COLLATE "default",
"password_hash" text COLLATE "default",
"phone_number" text COLLATE "default",
"phone_number_confirmed" bool NOT NULL,
"security_stamp" text COLLATE "default",
"two_factor_enabled" bool NOT NULL,
"user_name" varchar(256) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_claim
-- ----------------------------
DROP TABLE IF EXISTS "user_claim";
CREATE TABLE "user_claim" (
"id" int4 DEFAULT nextval('user_claim_id_seq'::regclass) NOT NULL,
"claim_type" text COLLATE "default",
"claim_value" text COLLATE "default",
"user_id" uuid NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of user_claim
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_login
-- ----------------------------
DROP TABLE IF EXISTS "user_login";
CREATE TABLE "user_login" (
"login_provider" text COLLATE "default" NOT NULL,
"provider_key" text COLLATE "default" NOT NULL,
"provider_display_name" text COLLATE "default",
"user_id" uuid NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of user_login
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS "user_role";
CREATE TABLE "user_role" (
"user_id" uuid NOT NULL,
"role_id" uuid NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of user_role
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_token
-- ----------------------------
DROP TABLE IF EXISTS "user_token";
CREATE TABLE "user_token" (
"user_id" uuid NOT NULL,
"login_provider" text COLLATE "default" NOT NULL,
"name" text COLLATE "default" NOT NULL,
"value" text COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of user_token
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Alter Sequences Owned By 
-- ----------------------------
ALTER SEQUENCE "role_claim_id_seq" OWNED BY "role_claim"."id";
ALTER SEQUENCE "user_claim_id_seq" OWNED BY "user_claim"."id";

-- ----------------------------
-- Indexes structure for table role
-- ----------------------------
CREATE UNIQUE INDEX "RoleNameIndex" ON "role" USING btree ("normalized_name");

-- ----------------------------
-- Primary Key structure for table role
-- ----------------------------
ALTER TABLE "role" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table role_claim
-- ----------------------------
CREATE INDEX "IX_role_claim_role_id" ON "role_claim" USING btree ("role_id");

-- ----------------------------
-- Primary Key structure for table role_claim
-- ----------------------------
ALTER TABLE "role_claim" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table user
-- ----------------------------
CREATE INDEX "EmailIndex" ON "user" USING btree ("normalized_email");
CREATE UNIQUE INDEX "UserNameIndex" ON "user" USING btree ("normalized_user_name");

-- ----------------------------
-- Primary Key structure for table user
-- ----------------------------
ALTER TABLE "user" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table user_claim
-- ----------------------------
CREATE INDEX "IX_user_claim_user_id" ON "user_claim" USING btree ("user_id");

-- ----------------------------
-- Primary Key structure for table user_claim
-- ----------------------------
ALTER TABLE "user_claim" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table user_login
-- ----------------------------
CREATE INDEX "IX_user_login_user_id" ON "user_login" USING btree ("user_id");

-- ----------------------------
-- Primary Key structure for table user_login
-- ----------------------------
ALTER TABLE "user_login" ADD PRIMARY KEY ("login_provider", "provider_key");

-- ----------------------------
-- Indexes structure for table user_role
-- ----------------------------
CREATE INDEX "IX_user_role_role_id" ON "user_role" USING btree ("role_id");

-- ----------------------------
-- Primary Key structure for table user_role
-- ----------------------------
ALTER TABLE "user_role" ADD PRIMARY KEY ("user_id", "role_id");

-- ----------------------------
-- Primary Key structure for table user_token
-- ----------------------------
ALTER TABLE "user_token" ADD PRIMARY KEY ("user_id", "login_provider", "name");

-- ----------------------------
-- Foreign Key structure for table "role_claim"
-- ----------------------------
ALTER TABLE "role_claim" ADD FOREIGN KEY ("role_id") REFERENCES "role" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Key structure for table "user_claim"
-- ----------------------------
ALTER TABLE "user_claim" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Key structure for table "user_login"
-- ----------------------------
ALTER TABLE "user_login" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Key structure for table "user_role"
-- ----------------------------
ALTER TABLE "user_role" ADD FOREIGN KEY ("role_id") REFERENCES "role" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "user_role" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

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

Re: Bug found: Guid primary key, always change?

Post by Shalex » Tue 06 Jun 2017 11:20

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

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

Re: Bug found: Guid primary key, always change?

Post by Shalex » Wed 28 Jun 2017 17:31

The new build of Entity Developer (v6.1.284) includes a fix of the issue. Please try it and notify us about the result.

RobertK
Posts: 56
Joined: Thu 02 Mar 2017 05:44

Re: Bug found: Guid primary key, always change?

Post by RobertK » Wed 12 Jul 2017 01:12

Shalex wrote:The new build of Entity Developer (v6.1.284) includes a fix of the issue. Please try it and notify us about the result.
Issue resolved.

Post Reply