Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DbContextOptionsBuilder does not contain a definition for 'UseSqlite'

Dotnet Core Web API throws when trying to use SQLite for my application

DbContextOptionsBuilder' does not contain a definition for 'UseSqlite' and no accessible extension method 'UseSqlite'

how to fix this?

I have tried using.Microsoft.EntityFrameworkCore;

using Microsoft.EntityFrameworkCore;

like image 547
Dev Ethio Avatar asked Oct 01 '19 08:10

Dev Ethio


1 Answers

I solved this problem by adding SQLite package.

On your startup file use this

using Microsoft.EntityFrameworkCore;

On your project file use this

<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1"/>

then you are ready to use SQLite

services.AddDbContext<DataContext>(x => 
    x.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
like image 168
Redwan Avatar answered Sep 26 '22 19:09

Redwan