Folks, SQLite columns can have INTEGER ... PRIMARY KEY AUTOINCREMENT which
produces the familiar behaviour we see in SQL Server where the key will
monotonically increase. See: http://www.sqlite.org/autoinc.html

 

If you omit the AUTOINCREMENT you get similar behaviour, but you can
optionally specify the value for the key and it will be used instead of
being generated. This seems quite good as you get the choice of having the
key generated by passing NULL, or only generated if you want by passing a
value.

 

However, the non-AUTOINCREMENT option is not so good with EF4 because if you
insert an entity and don't specify the key then zero is the default property
value and will be used as the key. The next insert will also use zero and
you get a duplicate and crash. This is simply because the primary key
property of the entity class will be public long and you can't set it to
null to let SQLite generate the value.

 

I'm just warning you about this quirk. I'm still pondering over it.

 

Greg

Reply via email to