SQLite on C# Cross-Platform Applications SQLite on C# Cross-Platform Applications sqlite sqlite

SQLite on C# Cross-Platform Applications


You can use csharp-sqlite which is a port to C# of Sql-Lite. It is very active and based on 3.6.22 version of SqlLite. See Miguel's comments on attempts to try to speed it up.


I've recently come across the issue too: building an application that uses Sqlite on Windows with Visual Studio and deploying it on an Ubuntu Server box for production.

The simplest solution I've found is using the Mono driver for Sqlite: Mono.Data.Sqlite.

Things could have been a little simpler but there is a bug with .Net 4.0 that is not yet packaged in the official Mono releases.

So you'll have to compile Mono from source (the general instructions are here):

  • first compile the whole Mono stuff
  • you do not need to install it if you want to keep your current Mono setup
  • copy the Mono.Data.Sqlite.dll library

Of course you can "cross-compile": I've built Mono on Ubuntu Server and used the dll in a Windows .Net project.

Then ensure you have the native Sqlite library (sqlite3.dll for Windows and sqlite3.so for Linux) in your library path: for Windows I simply copied the sqlite3.dll next to the Mono.Data.Sqlite.dll assembly, for Linux it should work out of the box.

You project should then work seamlessly in both Windows/.Net and Linux/Mono environments.


You can solve the naming differences using alias

#if (linux)  using SqlCommand = Mono.Data.Sqlite.SqliteCommand;#else  using SqlCommand = System.Data.SQLite;

Using different assemblies for different builds is a more complex task i think.. you can have a look at the MSBuild documentation