Generate SQL for SQLite database from Entity Framework Model
I was looking for a solution to this, when I stumbled upon this link: http://code.msdn.microsoft.com/Demo-of-ADONET-POCO-with-140ad3ad
Place the SSDLToSQLite3.tt file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen and you should be able to choose this as the DDL Generation Template in the Entity Designer.
Once you do that, the model will create SQL suited for SQLite.
The SSDLToSQLite3.tt
file seems to have a bug where primary keys are not defined for tables that have a single primary key that is not of the INTEGER PRIMARY KEY AUTOINCREMENT
variety.
The simplest change I found that does the trick is to change line 105
of the .tt
file from:
if (keyCount > 1)
to:
if (keyCount > 1 | (keyCount > 0 & autoIncreaseFieldName == string.Empty))