How to run SQLite EFCore 2.0 in LinqPad?

a simple code I was trying to help from StackOveflow:

nuget packages used:


program in C#

void Main()
var connection = new Microsoft.Data.Sqlite.SqliteConnection("DataSource=:memory:");


var options = new Microsoft.EntityFrameworkCore.DbContextOptionsBuilder()

var context = new TestDbContext(options);


var items = new List
new Item{Id = 1, Name = "Item 1", Price = 100},
new Item{Id = 2, Name = "Item 2", Price = 10},
new Item{Id = 3, Name = "Item 3", Price = 0},
new Item{Id = 4, Name = "Item 4", Price = -1},
new Item{Id = 5, Name = "Item 5", Price = -5}

var query1 = items.Where(x => x.Price > 0).Select(x => x.Name);
var results1 = query1.ToArray();
($"Items with price greater than 0 - {string.Join(",", results1)}").Dump("results 1");

var query2 = items.Where(x => x.Price > -1m).Select(x => x.Name);
var results2 = query2.ToArray();
($"Items with price greater than -1 - {string.Join(",", results2)}").Dump("results 2");

var query3 = items.Where(x => decimal.Negate(x.Price) < 1).Select(x => x.Name);
var results3 = query3.ToArray();
($"Items with price greater than -1 - {string.Join(",", results3)}").Dump("results 3");

public class Item
public long Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }

class TestDbContext : Microsoft.EntityFrameworkCore.DbContext
public TestDbContext(Microsoft.EntityFrameworkCore.DbContextOptions options) : base(options) { }
public Microsoft.EntityFrameworkCore.DbSet Items { get; set; }

I get an error:

> Unable to load DLL 'e_sqlite3': The specified module could not be found.

before I was getting

> Could not load file or assembly 'SQLitePCLRaw.provider.e_sqlite3...

but I could, somehow, move along

Thank you.


  • edited February 21
    I don't know. Try to find online the the best solution for it
  • So this was bugging me as well. Here is how I got it working.
    I happen to have a 4.7.1 project which was using the context as well. From the output folder of that project, I copied the following into the same directory as Linqpad. Maybe some of these are extra, but I was just happy to have it working, and not feeling like messing with it further.

  • I spent some time tracking this down for myself. I started manually looking at the package dependency graph and discovered the 'culprit'. The package 'SQLitePCLRaw.lib.e_sqlite3.v110_xp,Version=1.1.11' includes the native e_sqlite3.dll(s). The path for the x64 dll in the package is /runtimes/win-x64/native/e_sqlite3.dll. The path for the x86 dll is /runtimes/win-x86/native/e_sqlite3.dll.

    To get SQLite working in LINQPad, I've done the following:

    === One time step ===
    1. In the folder that contains your LINQPad.exe, create the folders ./x64 and ./X86.
    2. From the package SQLitePCLRaw.lib.e_sqlite3.v110_xp, extract the e_sqlite3.dll(s) into their corresponding folders;i.e., ../win-x64/.. into x64 and ../win-x86/.. into x86.
    3. Your LINQPad folder should look like this:

    4. If you have LINQPad.exe running, you will need to restart the process.

    === When creating an EntityFrameworkCore SQLite snippet ===
    5. Add NuGet reference to 'SQLitePCLRaw.provider.e_sqlite3.net45'

    * Note. I do this for both the LINQPad_AnyCPU version and the LINQPad_x86 version (64bit machines). It's just easier to copy that folder structure to all my machines ;-)

    I've not searched the forums (linqpad) to see if there's a way to handle nuget packages that include native assemblies; there may be an opportunity here (to update LINQPAD to handle native dlls from packages).

    For some interesting reading about the sqlite packages involved, see .
  • As an aside, I was able to rename sqlite3.dll from the official site from "' into the x64 folder as 'e_sqlite3.dll' and it worked.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!