This question is locked. New answers and comments are not allowed.
I have a valid SQLite database file from which I am trying to generate a model. When I do that, OA (v.2013.2.702.1) incorrectly determines PK fields and shows errors in the model. Here is SQL used to generate the database:
-- ----------------------------
-- Table structure for "main"."RuleEntities"
-- ----------------------------
CREATE TABLE "RuleEntities" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityName" TEXT NOT NULL,
CONSTRAINT "UQ_Entities_EntityName" UNIQUE ("EntityName")
);
-- ----------------------------
-- Table structure for "main"."DeleteRules"
-- ----------------------------
CREATE TABLE "DeleteRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"Name" TEXT NOT NULL,
CONSTRAINT "FK_DeleteRules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_Name" UNIQUE ("Name" ASC, "EntityId" ASC)
);
-- ----------------------------
-- Table structure for "main"."IgnoredDuplicates"
-- ----------------------------
CREATE TABLE "IgnoredDuplicates" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"BookId" INTEGER NOT NULL,
"DuplicateBookId" INTEGER NOT NULL,
CONSTRAINT "UQ_BookId_DupBookId" UNIQUE ("BookId", "DuplicateBookId")
);
-- ----------------------------
-- Table structure for "main"."RegexRenameRules"
-- ----------------------------
CREATE TABLE "RegexRenameRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"FromName" TEXT NOT NULL,
"ToName" TEXT NOT NULL,
CONSTRAINT "FK_Rules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_FromName_ToName" UNIQUE ("EntityId", "FromName")
);
-- ----------------------------
-- Table structure for "main"."SimpleRenameRules"
-- ----------------------------
CREATE TABLE "SimpleRenameRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"FromName" TEXT NOT NULL,
"ToName" TEXT NOT NULL,
CONSTRAINT "FK_SimpleRenameRules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_FromName_ToName" UNIQUE ("EntityId" ASC, "FromName" ASC)
);
Errors in the model:
Warning 10 The identity field of the persistent class 'Calibre.DalOpenAccess.SimpleRenameRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 9 The identity field of the persistent class 'Calibre.DalOpenAccess.RuleEntity' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 8 The identity field of the persistent class 'Calibre.DalOpenAccess.RegexRenameRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 7 The identity field of the persistent class 'Calibre.DalOpenAccess.IgnoredDuplicate' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 6 The identity field of the persistent class 'Calibre.DalOpenAccess.DeleteRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Error 5 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the SimpleRenameRules table. This is not currently supported. 0 0
Error 4 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the RuleEntities table. This is not currently supported. 0 0
Error 3 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the RegexRenameRules table. This is not currently supported. 0 0
Error 2 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the IgnoredDuplicates table. This is not currently supported. 0 0
Error 1 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the DeleteRules table. This is not currently supported. 0 0
Am I doing something wrong or is there an issue with the product?
-- ----------------------------
-- Table structure for "main"."RuleEntities"
-- ----------------------------
CREATE TABLE "RuleEntities" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityName" TEXT NOT NULL,
CONSTRAINT "UQ_Entities_EntityName" UNIQUE ("EntityName")
);
-- ----------------------------
-- Table structure for "main"."DeleteRules"
-- ----------------------------
CREATE TABLE "DeleteRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"Name" TEXT NOT NULL,
CONSTRAINT "FK_DeleteRules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_Name" UNIQUE ("Name" ASC, "EntityId" ASC)
);
-- ----------------------------
-- Table structure for "main"."IgnoredDuplicates"
-- ----------------------------
CREATE TABLE "IgnoredDuplicates" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"BookId" INTEGER NOT NULL,
"DuplicateBookId" INTEGER NOT NULL,
CONSTRAINT "UQ_BookId_DupBookId" UNIQUE ("BookId", "DuplicateBookId")
);
-- ----------------------------
-- Table structure for "main"."RegexRenameRules"
-- ----------------------------
CREATE TABLE "RegexRenameRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"FromName" TEXT NOT NULL,
"ToName" TEXT NOT NULL,
CONSTRAINT "FK_Rules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_FromName_ToName" UNIQUE ("EntityId", "FromName")
);
-- ----------------------------
-- Table structure for "main"."SimpleRenameRules"
-- ----------------------------
CREATE TABLE "SimpleRenameRules" (
"Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"EntityId" INTEGER NOT NULL,
"FromName" TEXT NOT NULL,
"ToName" TEXT NOT NULL,
CONSTRAINT "FK_SimpleRenameRules_EntityId" FOREIGN KEY ("EntityId") REFERENCES "RuleEntities" ("Id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "UQ_FromName_ToName" UNIQUE ("EntityId" ASC, "FromName" ASC)
);
Errors in the model:
Warning 10 The identity field of the persistent class 'Calibre.DalOpenAccess.SimpleRenameRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 9 The identity field of the persistent class 'Calibre.DalOpenAccess.RuleEntity' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 8 The identity field of the persistent class 'Calibre.DalOpenAccess.RegexRenameRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 7 The identity field of the persistent class 'Calibre.DalOpenAccess.IgnoredDuplicate' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Warning 6 The identity field of the persistent class 'Calibre.DalOpenAccess.DeleteRule' is mapped to a backend calculated column but the class does not use the Backend Calculated key generator 0 0
Error 5 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the SimpleRenameRules table. This is not currently supported. 0 0
Error 4 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the RuleEntities table. This is not currently supported. 0 0
Error 3 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the RegexRenameRules table. This is not currently supported. 0 0
Error 2 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the IgnoredDuplicates table. This is not currently supported. 0 0
Error 1 The column Id is specified as 'AUTOINC' and it is also part of the composite primary key of the DeleteRules table. This is not currently supported. 0 0