Creating Model from Database, not creating complex primary keys

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
HadleyHope
Posts: 8
Joined: Thu 24 Jan 2013 14:44

Creating Model from Database, not creating complex primary keys

Post by HadleyHope » Fri 30 Aug 2013 09:58

I have several tables that have more than one field involved in the primary key, it seems after a recent update that Entity Developer only marks the first key of the table as the primary key. This is cause a lot of problems with queries, for example this query

Code: Select all

     var query = from r in _table
     where r.CountryId == item.RowData.CountryId
         && r.GDPType == item.RowData.GDPType
         && r.CurrencyCode == item.RowData.CurrencyCode
     select r;
returns the correct number of items, but all items are populated with the values from the first row only!

dotConnect for SQLite Version: 4.6.301.0
Server Version: 3.7.17
PRAGMA synchronous=NORMAL
PRAGMA journal_mode=WAL

Example table:

Code: Select all

CREATE TABLE GDPData (
  CountryId     smallint NOT NULL,
  GDPType       smallint NOT NULL,
  Year          smallint NOT NULL,
  CurrencyCode  char(3) NOT NULL,
  Value         numeric(50,6) DEFAULT NULL,
  Source        nvarchar(100) DEFAULT NULL,
  UserDefined   boolean NOT NULL DEFAULT 0,
  PrevBatchIds  nvarchar(50) DEFAULT NULL,
  BatchId       integer DEFAULT NULL,
  PRIMARY KEY (CountryId, GDPType, Year, CurrencyCode),
  /* Foreign keys */
  FOREIGN KEY (CountryId)
    REFERENCES Country(Id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE, 
  FOREIGN KEY (CurrencyCode)
    REFERENCES Currency(Code)
    ON DELETE NO ACTION
    ON UPDATE CASCADE, 
  FOREIGN KEY (GDPType)
    REFERENCES GDPType(Id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE
);

CREATE INDEX GDPDataIdx_Country
  ON GDPData
  (CountryId);

CREATE INDEX GDPDataIdx_CurrencyCode
  ON GDPData
  (CurrencyCode);

CREATE INDEX GDPDataIdx_CurrencyType
  ON GDPData
  (CurrencyCode, GDPType, CountryId, Year);

CREATE INDEX GDPDataIdx_Type
  ON GDPData
  (GDPType);

Example Data:
INSERT INTO GDPData (CountryId, GDPType, Year, CurrencyCode, Value, Source, UserDefined, PrevBatchIds, BatchId) VALUES
  (4, 1, 1960, 'USD', 1210000077, 'NULL', '1', 'NULL|4', 8),
  (4, 1, 1961, 'USD', 1235000013, 'NULL', '1', 'NULL|4', 8),
  (4, 1, 1962, 'USD', 1230000026, 'NULL', '1', 'NULL|4', 8),
  (4, 1, 1963, 'USD', NULL, 'NULL', '1', 'NULL|4', 8),
  (4, 1, 1964, 'USD', 800000045.5, 'NULL', '1', 'NULL|4', 8);

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

Re: Creating Model from Database, not creating complex primary keys

Post by Shalex » Fri 06 Sep 2013 17:48

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

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Creating Model from Database, not creating complex primary keys

Post by MariiaI » Tue 24 Sep 2013 07:17

The bug with creating complex primary keys when creating a model from a database is fixed.
New build of dotConnect for SQLite 4.6.333 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/sqlite/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=29&t=27978.

Post Reply