Model first with SQLite

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Mystcreater
Posts: 6
Joined: Wed 23 Feb 2011 03:15
Location: CA

Model first with SQLite

Post by Mystcreater » Wed 23 Feb 2011 12:16

Hi,

I tried to use the model first approach with a SQLite database and when I add a column in a table and then use the option "Update Database with model", the table in the database is deleted and recreated without keeping the rows alive.

I know that SQLite don't allow deleting column on an existing table but in this case, you should create a temporary table, copy all the rows to this table, delete the table, create a new table without the deleted column, copy all the rows from the temporary table and then delete the temporary table.

Here is a sample of code from the web site of SQLite:

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;

Thank you

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 24 Feb 2011 15:59

It is not guaranteed that the Update To Database wizard keeps data safe in all cases. Provided that the database does not support the ALTER statement needed in a particular case, the whole table will be dropped and re-created.

We will consider implementing backups for such cases in future, but cannot provide any timeframe for this.

Post Reply