This is a migrated thread and some comments may be shown as answers.

Issues generating model from SQLite database

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mensur
Top achievements
Rank 1
Mensur asked on 21 Aug 2013, 02:33 PM
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?

3 Answers, 1 is accepted

Sort by
0
Mensur
Top achievements
Rank 1
answered on 21 Aug 2013, 03:44 PM
To provide a little more detail, it appears that OA is getting confused by a UNIQUE constraint on some of the tables and is thinking that those columns are a part of the composite primary key which they are not. To fix the problem, I had to manually change the primary key column on all tables, set the identity generation to backend generate autoinc and finally set the identity type to SingleField. OA should be able to detect this from the start. This smells like a bug to me. In addition, none of the FK constraints were brought in and I had to manually create associations - another problem.
0
Boris Georgiev
Telerik team
answered on 27 Aug 2013, 07:03 PM
Hi Mensur,

Thank you for reporting this issue. Such a problem has never been reported, so we will have to investigate the problem in more details and will let you know as soon as we have more information.

Please excuse us for the inconvenience caused.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Boris Georgiev
Telerik team
answered on 31 May 2014, 12:24 PM
Hello Mensur,

A part from this issue has been fixed with one of the previous version of Telerik Data Access. Now there shouldn't be any validation errors in the model and the columns with Unique constraint should not be mapped as a primary key properties. Unfortunately a new bug linked to this issue has been discovered and now the Foreign Key columns are created as a primary key properties in the model.

The bug has been logged in our backlog, but we were not able to fix it for previous releases. Unfortunately we cannot give you an estimate, when the bug fix will be delivered.

Please excuse us for the inconvenience caused.

Regards,
Boris Georgiev
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Mensur
Top achievements
Rank 1
Answers by
Mensur
Top achievements
Rank 1
Boris Georgiev
Telerik team
Share this question
or