Menu

Using Sqlite in ASP.NET Core

Not always you have access to a sql server, localDb or SQl Express, or you dont want to have a big database for your sample application you are playing around, or application you are developing going to be run on a micro computer like Raspberry Pi. Good alternative is Sqlite. easy , simple and light weight.

Fist install NuGet

Microsoft.EntityFrameworkCore.Sqlite

In your appsettings.json file set the connection string

"ConnectionStrings": { 
"DefaultConnection": "Data Source=D:\\database.sqlite"
},

on your Startup.cs in the ConfigureServices section define the databse option like below

services.AddDbContext<ExchangeMonitorContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));

that is it. This is why I love ASP.NET Core – simple and flexible.

important thing to remember is Sqlite does not support DefaultSchema in your DbContext.

Leave a comment