asp.netdbcontext

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;


Solution

  • 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")));