Save Big on Cyber Monday! Up to 40% Off
ends in   {{days}}
Days
{{timeFormat.hours}}
:
{{timeFormat.minutes}}
:
{{timeFormat.seconds}}

Getting Started With dotConnect for SQLite

Below are some resources to help you maximize your experience with dotConnect for SQLite.

dotConnect for SQLite is a high-performance ADO.NET data provider with ORM support, offering fast and encrypted access to SQLite databases for application development.

  • EF Core, Dapper, NHibernate, LinqConnect, and other ORMs support
  • Advanced encryption methods
  • Broad compatibility with various .NET platforms and versions
  • Full compliance with ADO.NET
  • Integration with Visual Studio

Code examples

using Devart.Data.SQLite;

namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string databasePath = @"path\to\your\sakila.db;";

            string connectionString = $"Data Source={databasePath};License Key=**********";

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    Console.WriteLine("Connection successful!");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Connection failed: {ex.Message}");
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }

}
PM> Install-Package Devart.Data.SQLite
using Devart.Data.SQLite;

namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string databasePath = @"path\to\your\sakila.db";

            string connectionString = $"Data Source={databasePath};Encryption=AES256;FailIfMissing=false;Password=best;License Key=**********";

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    Console.WriteLine("Connection successful!");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Connection failed: {ex.Message}");
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
}
PM> Install-Package Devart.Data.SQLite
using Devart.Data.SQLite;

namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = @"Data Source=path\to\your\sakila.db;License Key=**********";

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    Console.WriteLine("Connection successful!\n");

                    string query = "SELECT ActorId, FirstName, LastName FROM Actor LIMIT 15";

                    using (SQLiteCommand command = new SQLiteCommand(query, connection)) 
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        Console.WriteLine("ActorId\tFirstName\tLastName");
                        Console.WriteLine("-------\t---------\t--------");

                        while (reader.Read())
                        {
                            Console.WriteLine($"{reader["ActorId "]}\t{reader["FirstName "]}\t\t{reader["LastName "]}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                }
            }

            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
    }
}
PM> Install-Package Devart.Data.SQLite
using System;
using System.Linq;
using Devart.Data.SQLite.EFCore;
using Microsoft.EntityFrameworkCore;

namespace EfCoreDotConnectSqliteDemo
{

    public class Actor
    {
        public int ActorId { get; set; }
        public string FirstName { get; set; } = "";
        public string LastName { get; set; } = "";
        public DateTime LastUpdate { get; set; }
    }

    public class SakilaContext : DbContext
    {
        private readonly string _connectionString;

        public SakilaContext(string connectionString) => _connectionString = connectionString;

        public DbSet Actors => Set();

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSQLite(_connectionString);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            var e = modelBuilder.Entity();
            e.ToTable("Actor");
            e.HasKey(a => a.ActorId);
            e.Property(a => a.ActorId).HasColumnName("ActorId");
            e.Property(a => a.FirstName).HasColumnName("FirstName");
            e.Property(a => a.LastName).HasColumnName("LastName");
            e.Property(a => a.LastUpdate).HasColumnName("LastUpdate");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var connString = @"Data Source=path\to\your\sakila.db;License Key=**********";
            using
            var db = new SakilaContext(connString);
            Console.WriteLine("Fetching first 15 actors...\n");
            var actors = db.Actors.OrderBy(a => a.ActorId).Take(15).Select(a => new {
                a.ActorId,
                a.FirstName,
                a.LastName,
            }).ToList();
            Console.WriteLine("ActorId\tFirstName\tLastName");
            Console.WriteLine("-------\t---------\t--------");
            foreach (var a in actors)
            {
                Console.WriteLine($"{a.ActorId}\t{a.FirstName, -10}\t{a.LastName}");
            }
            Console.WriteLine("\nDone. Press any key to exit...");
            Console.ReadKey();
        }
    }
}
PM> Install-Package Devart.Data.SQLite.EFCore
using Devart.Data.SQLite;
using System.Data;
namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = @"Data Source=path\to\your\sakila.db;License Key=**********";
            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    Console.WriteLine("Connection successful!\n");
                    string query = "SELECT ActorId, FirstName, LastName FROM Actor LIMIT 15";

                    SQLiteDataAdapter adapter = new SQLiteDataAdapter(query, connection);

                    DataTable table = new DataTable();
                    adapter.Fill(table);

                    Console.WriteLine("ActorId\tFirstName\tLastName");
                    Console.WriteLine("-------\t---------\t--------");
                    foreach (DataRow row in table.Rows)
                    {
                        Console.WriteLine($"{row["ActorId "]}\t{row["FirstName "],-10}\t{row["LastName "]}");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                }
            }
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
    }
}
PM > Install-Package Devart.Data.SQLite
using Devart.Data.SQLite;
namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {

            string connectionString = @"Data Source=path\to\your\sakila.db;License Key=**********";
            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                connection.Open();
                Console.WriteLine("Connection successful!\n");

                SQLiteTransaction transaction = connection.BeginTransaction();
                try
                {
                    string insertSql = "INSERT INTO Actor (FirstName, LastName, LastUpdate) " + "VALUES (@FirstName, @LastName, CURRENT_TIMESTAMP)";
                    using (SQLiteCommand cmd = new SQLiteCommand(insertSql, connection))
                    {
                        cmd.Transaction = transaction;
                        cmd.Parameters.AddWithValue("@FirstName", "JANE");
                        cmd.Parameters.AddWithValue("@LastName", "SMITH");
                        int rows = cmd.ExecuteNonQuery();
                        Console.WriteLine($"{rows} row(s) inserted.");
                    }

                    transaction.Commit();
                    Console.WriteLine("Transaction committed successfully.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);

                    transaction.Rollback();
                    Console.WriteLine("Transaction rolled back.");
                }
            }
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
    }
}
PM> Install-Package Devart.Data.SQLite
using Devart.Data.SQLite;
namespace SQLiteConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {

            string connectionString = @"Data Source=path\to\your\sakila.db;License Key=**********";
            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();
                    Console.WriteLine("Connection successful!\n");

                    string sql = "INSERT INTO Actor (FirstName, LastUpdate) VALUES (@FirstName, CURRENT_TIMESTAMP)";
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, connection))
                    {
                        cmd.Parameters.AddWithValue("@FirstName", "ONLY_FIRSTNAME");
                        int rows = cmd.ExecuteNonQuery();
                        Console.WriteLine($"{rows} row(s) inserted.");
                    }
                }
                catch (SQLiteException ex) // dotConnect-specific exception
                {
                    Console.WriteLine("SQLiteException caught!");
                    Console.WriteLine($"Error Code: {ex.ErrorCode}");
                    Console.WriteLine($"Message   : {ex.Message}");
                }
                catch (Exception ex) // fallback for other runtime errors
                {
                    Console.WriteLine("General Exception caught!");
                    Console.WriteLine($"Message: {ex.Message}");
                }
            }
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
    }
}
PM> Install-Package Devart.Data.SQLite

Demo videos

How-to articles

.NET SQLite Connection Strings
Learn how to set up connection strings properly when working with dotConnect for SQLite in .NET applications.
Connect to SQLite in .NET
Explore how to establish a connection between .NET applications and SQLite using ADO.NET.
Connect to SQLite with EF Core
Find out how to connect SQLite databases to your application using EF Core and ADO.NET.
Connect to SQLite with Dapper
Learn how to connect C# to SQLite using Dapper for fast and efficient data access.
Connect to SQLite in Blazor
Learn how to integrate SQLite with .NET Blazor applications using EF Core and ADO.NET.
Connect to SQLite in MAUI
See how to build .NET MAUI applications and perform CRUD operations with SQLite using ADO.NET.

Documentation

Licensing
Licensing
A detailed technical reference on embedding license information - a required resource for applications built with dotConnect for SQLite.
DataTable Features
DataTable features
A guide to using the SQLiteDataTable component and its features, like server connections, command objects, data storage, and data access.
Parameters
Parameters
An overview of SQL query parameters and their synchronization, along with practical insights into working with stored procedures.
Specific Features
Specific features
An explanation of support for SQLite-specific features, including integrated encryption, embedded server mode, and efficient connection handling.

dotConnect Universal

Get universal access to data from a variety of sources, including SQL Server, Oracle, PostgreSQL, MySQL, SQLite, DB2, InterBase, Microsoft Access, and Firebird. Other servers can be accessed through their ADO.NET, OLE DB and ODBC providers.

FAQ

What is the trial period for dotConnect for SQLite?
dotConnect for SQLite offers a fully functional 30-day trial. During this period, you can use and evaluate all features without limitations. After the trial ends, you can purchase a license to keep using the product.
Why do I need to install the product if NuGet is available?

dotConnect for SQLite provides two sets of assemblies, and the choice depends on your project type:

  • For .NET Framework projects: Use the Devart assemblies included with the product installer.
  • For .NET (.NET Core/.NET 5+) projects: Use the assemblies available via NuGet packages.
Where should I apply my License Key?

The method for applying your license depends on your project type:

  • For .NET (.NET Core/.NET 5+) projects, apply the License Key at runtime using the License Key connection string parameter.
  • For .NET Framework projects, no license key is needed. Simply download and install the licensed version of dotConnect from your Devart Customer Portal.
What editions of dotConnect for SQLite are available, and what's the difference?

There are three editions:

  • Express - Free version with basic connectivity.
  • Standard - Full ADO.NET provider with design-time support.
  • Professional - Adds ORM tools like Entity Framework and LinqConnect.
Do end users of my application need a Devart license, or do I have to pay additional fees for deploying my software?

No, end users do not need a Devart license, and there are no additional deployment fees, as long as you hold a valid Devart license.

According to the EULA, you're allowed to redistribute the following runtime assemblies with your application:

  • Devart.Data.SQLite.dll
  • Devart.Data.dll

You can include them in your app's folder (such as Bin for web apps) or register them in the GAC. Just make sure they are only used by your solution.

There's no need for a full installation on the target machine, you can also use the "Minimal installation" option provided by the setup.

No other components of dotConnect may be distributed.

How can I update dotConnect to a new version?

To update dotConnect to a new version, you need to reinstall it:

  • 1. Open Settings > Apps > Installed apps in Windows.
  • 2. Uninstall the current and any older versions of dotConnect, including Entity Developer and LinqConnect, if installed.
  • 3. Visit the Customer Portal and download the latest licensed version.
  • 4. Install the downloaded version and receive the latest features and improvements.
How can I completely remove all previous versions of a product?

1. Go to Settings > Apps > Installed apps and uninstall:

  • All dotConnect providers
  • Entity Developer
  • LinqConnect

2. Manually delete any leftover files from the following locations (if they exist):

GAC folders:

  • C:\Windows\assembly\GAC_MSIL
  • C:\Windows\Microsoft.NET\assembly\GAC_MSIL

Program files and extensions:

  • C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Devart
  • C:\Program Files (x86)\Devart
  • C:\Program Files\Devart
  • C:\Program Files (x86)\Common Files\Devart
  • C:\Program Files\Common Files\Devart

Program data folders:

  • C:\ProgramData\Devart\dotConnect
  • C:\ProgramData\Devart\Entity Developer
  • C:\ProgramData\Devart\EntityDeveloper

Removing these ensures a clean system and prevents conflicts during future installations.

dotConnect for SQLite

Get an enhanced ORM-enabled data provider for SQLite and develop .NET applications working with SQLite data quickly and easily!

Discover the ultimate capabilities of dotConnect for SQLite Download free trial