Aspnetcore.docs: Error: 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlite'

Created on 6 Jul 2018  Â·  19Comments  Â·  Source: dotnet/AspNetCore.Docs

After registering the database context when attempting to build, this error appears:

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?)

Searched a lot, installed SQLite from https://www.nuget.org/packages/System.Data.SQLite/ , tried searching, all without success. What am I missing? (or what is missing from the step-by-step instructions)?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms

Most helpful comment

Adding <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1"/> to a new ItemGroup in the csproj and then restoring seemed to resolve the issue.

All 19 comments

@dasoussan You're missing the following code at the top of your Startup.cs file:

using Microsoft.EntityFrameworkCore;

I'll update this section of the tutorial to make the 2 required using statements more obvious.

I'm running into the same issue, but I have the above using statement.
Closing and re-opening VS Code removes the error but the build still fails with the same error CS1061
Something pretty funky is going on here.

Adding <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1"/> to a new ItemGroup in the csproj and then restoring seemed to resolve the issue.

I ran into the same issue today, while trying to follow the tutorial, but the comment from Smilebags seems to work for me too.. The tutorial should probably be updated.

Edit: I started from the cross platform tutorial using VS Code.

This is still a problem BTW. I'm not sure what the reason is either. I've tried the suggestions by @Smilebags but to no avail. I keep getting this error.

image

It doesn't really make sense - the classes are in the right place and the import is correct so what's wrong?

That's a really great error message. Add the right using

@Rick-Anderson Love the sarcasm.....
image

I restarted VS Code and the error was gone. Appreciate the help..... seriously. Thanks.

Adding <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1"/> to a new ItemGroup in the csproj and then restoring seemed to resolve the issue.

Thank you, this solution works for me in creating the MVCmovie VS CODE tutorial

@Smilebags Kudos, That solved it

FYI, 2019, @Smilebags comment is still the solution. Thanks dude.

I just changed the Microsoft.EntityFrameworkCore.Sqlite version with NuGet package manager.

On the terminal I ran 'dotnet add package Microsoft.EntityFrameworkCore.Sqlite' and it worked for me.

Just install Microsoft.EntityFrameworkCore.InMemory package and it will fix the issue

add package Microsoft.EntityFrameworkCore.Sqlite

@dasoussan Thank you! I have been trying for 3 days before I found your solution!

That's in the tutorial
image

Adding the Microsoft.EntityFrameworkCore.InMemory package helped me with the issue.

https://stackoverflow.com/a/56684097/5834961.

That's in the tutorial
image

Was this page helpful?
0 / 5 - 0 ratings