user11065510
user11065510

Reputation:

In ASP.NET Core, how to use sqlite

I tried to create a rest api . when I try to change

 services.AddDbContext<WebContext>(options =>

   options.useSqlite(Configuration.GetConnectionString("WebContext")));

when I try to do this I get this error. I installed sqlite nuget.and also Microsoft.EntityFrameworkCore but I still got the problem

error CS1061: 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlite' and no extension method 'UseSqlite' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?

Upvotes: 1

Views: 2299

Answers (1)

yv989c
yv989c

Reputation: 1533

Try:

using Microsoft.EntityFrameworkCore;
...
services.AddDbContext<WebContext>(options => 
    options.UseSqlite(Configuration.GetConnectionString("WebContext")));
...

And you also need to install the Microsoft.EntityFrameworkCore.Sqlite nuget package.

Upvotes: 2

Related Questions