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! Now you should be able to select the new template in the Visual Studio designer and enjoy the newly SQLite compatible SQL script.
May 16, 2012 at 6:27 am |
hi there,
seems that the zip has gone 😦
May 16, 2012 at 7:51 am |
Hey, sorry for that. It’s working again now.
March 4, 2016 at 8:32 pm |
What modifications did you make?
(I’m on Visual Studio 2015; Entity Framework 6; .NET 4.6)
January 24, 2020 at 5:31 pm |
And the script is gone again