Generate Entity-Framework DDL-Script for SQLite

By default the Entity Framework designer for Visual Studio only generates DDL Scripts for Microsoft SQL Server (CE).

However you can change the template file (.tt) which is used to generate the SQL statements. Just click on empty space in the designer and take a look in the property sheet window.

The default template is called SSDLToSQL10.tt and resides in a subfolder of the Visual Studio program files directory.

For one of my projects I needed the generated SQL to be compatible with SQLite, so I modified the original file for SQLite and created a new version, which you can download below.

After downloading the files and putting them in the correct directories, you should be able to select them inside the EF designer.

Keep in mind that I can’t give any guarantees that this files will work as you expect. I wrote them specifically for my project and I’m just sharing them in the hopes that they are useful for anyone.

Download the following zip file: SQLiteGen.zip

You will find 2 files in the zip file:

Put the SSDLToSQLite.tt file in the directory
.\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\

Put the GenerateSQL.Utility.ttinclude file in the directory
.\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\

You are done! Smiley Now you should be able to select the new template in the Visual Studio designer and enjoy the newly SQLite compatible SQL script.

Advertisement

4 Responses to “Generate Entity-Framework DDL-Script for SQLite”

  1. bar Says:

    hi there,
    seems that the zip has gone 😦

  2. akzent Says:

    Hey, sorry for that. It’s working again now.

  3. muntoo Says:

    What modifications did you make?

    (I’m on Visual Studio 2015; Entity Framework 6; .NET 4.6)

  4. Alex Says:

    And the script is gone again

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: