File not found when using EF Core with SQLite: SQLitePCLRaw.provider.e_sqlite3

Hey, I am trying to run EntityFramework Core with the SQLite provider and I am getting a FileNotFound exception for SQLitePCLRaw.provider.e_sqlite3 when trying to use it.

This is the script I use to test this:
void Main()
{
var dbContextOptions = new DbContextOptionsBuilder().UseSqlite("Data Source=C:\\foo.db").Options;
using (var db = new MyDbContext(dbContextOptions))
{
db.Database.EnsureCreated();
}
}

public class MyDbContext : DbContext
{
public MyDbContext(DbContextOptions options) : base(options)
{ }
}
The query only has a reference to Microsoft.EntityFrameworkCore.Sqlite (and System.ValueTuple which I believe I still need because I am still running on .NET 4.7.0?)

Any idea why this doesn’t work? I assume that the NuGet reference prevents the SQLite library from being provided here which causes the problem. I also tried referencing that NuGet package directly from the query but that also didn’t work.

Comments

  • Download the latest beta and then edit the connection properties. You'll see a option to add NuGet references. Click this and add a reference to the missing SQLite package.
  • Thanks for your reply but I’m not sure if I understand this correctly.

    I do not want to use LINQPad’s own database provider/connector here but instead would just like to use above code to connect to the database (since that’s also what you would do in a standalone project, with just a single NuGet package reference to EFCore.Sqlite). Is there a way to make that work?

    I’ve tried adding the connection through the “Add connection” dialog just to test it, but I don’t see where I would select SQLite. If I select the EF Core driver for a typed data context, it appears that I have to select another assembly with the context first (although I would like to define the context within the query).
Sign In or Register to comment.