Using latest versions of EF6 and SQLite from NuGet. I finally got the app.config file to work after some useful posts on Stackoverflow. Now the problem is that the tables ar
I decided to write my own rudimentary database initializer to solve this problem.
You can check it out here: https://gist.github.com/flaub/1968486e1b3f2b9fddaf
It supports:
The same to you. I have used Compact 4.0 instead of Sqlite.
As a reference:
I started with the code from fried and created a project which lets you use CodeFirst. The project is available open source on GitHub or as NuGet Package.
If you encounter any problems or miss a feature, feel free to open a new issue on GitHub. Of course PRs are very welcome.
Edit (26.04.2016):
In the meantime I did a lot in this project.
The following (default EF) functionality is supported:
There are also some features exclusive for SQLite, which are not supported by default:
There are two ways to use the functionality of this library.
Make use of the DbInitializers:
Get more control by using one of the following two classes:
Edit (30.05.2020): As EF 6 now supports .NET Core 3 and above, I adjusted the library to support .NET Standard 2.1 as well. The following .NET framework versions are supported:
Unfortunately, the EF6 provider implementation in System.Data.SQLite.EF6
doesn't support creating tables. I downloaded the SQLite source code to have a look but couldn't find anything for creating tables and for migrations. The EF6 provider is basically the same as their Linq implementation so it's all aimed at querying the database rather than modifying it.
I currently do all of my work with SQL Server and generate sql scripts for SQLite using the SQL Server Compact & SQLite Toolbox. The scripts can then be run using an SQLiteCommand
to simulate migrations.
Update
In EF7 support for SQL server compact has been dropped and a new provider for SQLite is being developed by the EF team. The provider will use Microsoft's managed SQLite wrapper project, Microsoft.Data.SQLite rather than the System.Data.SQLite
project. This will also allow for using EF7 on iOS, Android, Windows Phone / Mobile, Linux, Mac etc. as Microsoft's wrapper is being developed as a portable library.
It's all still in beta but you can get nuget packages from the ASP.Net development feeds at MyGet (dev, master, release) if you wish to have a look. Look for the EntityFramework.SQLite
package.