Missing definition for UseSqlite in DbContextOptionsBuilder class of Microsoft.EntityFrameworkCore.Tool
Asked Answered
G

4

15

I'm trying to write a simple phone app using UWP that will insert an image from a Windows folder location into a table on SQLite and view it on the Windows phone.

I found this article on technet forum that I am using for a reference:

https://social.technet.microsoft.com/wiki/contents/articles/37975.save-and-load-images-in-universal-windows-app-with-sqlite-and-entity-framework-core.aspx

While following the instructions, I ran into an issue in installing the package Microsoft.EntityFrameworkCore.Tools (latest stable ver.2.0.1):

PM>  Install-Package Microsoft.EntityFrameworkCore.Tools
  GET https://api.nuget.org/v3/registration3-gz/microsoft.entityframeworkcore.tools/index.json
  OK https://api.nuget.org/v3/registration3-gz/microsoft.entityframeworkcore.tools/index.json 74ms
Restoring packages for c:\users\intui\documents\visual studio 2017\Projects\PicturesApp\PicturesApp\PicturesApp.csproj...
Install-Package : Package Microsoft.EntityFrameworkCore.Tools 2.0.1 is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586). Package 
Microsoft.EntityFrameworkCore.Tools 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:2
+  Install-Package Microsoft.EntityFrameworkCore.Tools
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Same issue also occured with the previous version (2.0.0), but the next previous version (1.1.4) was installed successfully.

However, I found that the "DbContextOptionsBuilder" class used in the code "PictureAppContext" class does not recognize the method "UseSqlite":

Severity    Code    Description Project File    Line    Suppression State 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?)   PicturesApp c:\users\intui\documents\visual studio 2017\Projects\PicturesApp\PicturesApp\PictureAppContext.cs   16  Active

Anyone knows how resolve this issue?

Thanks!

Gonta answered 19/11, 2017 at 15:49 Comment(3)
Have you installed the 2.0.1 SQLite package?Hamrick
Yes. I installed Microsoft.EntityFrameworkCore.Sqlite before running the installation for Microsoft.EntityFrameworkCore.Tools.Gonta
I also included in the project reference "SQLite for Universal Windows Platform" ver.3.18.0Gonta
T
22

I ran into this same issue using dotnet sdk 2.1.1 which was supposed to have all basic dependencies wrapped in Microsoft.AspnetCore.App. All i needed to do was run dotnet add package Microsoft.EntityFrameworkCore.Sqlite in a terminal window in the project directory (The directory that contains the Program.cs, Startup.cs, and .csproj files)

Triadelphous answered 27/6, 2018 at 13:10 Comment(1)
Install-Package Microsoft.EntityFrameworkCore.SqliteNewland
R
5

For .NET 5, I had to install the package Microsoft.EntityFrameworkCore.Sqlite.Core

Check the link

Ribosome answered 14/12, 2020 at 13:42 Comment(1)
I did the same for .net 6. I wanted to write some unit tests and the tutorial I am following, menitioned only Microsoft.EntityFrameworkCore as a required package for the test project. Then I got this error, installed the .sqilite.core and it worked.Iota
G
1

I added using Microsoft.EntityFrameworkCore; as suggested in the GitHub issue (https://github.com/dotnet/AspNetCore.Docs/issues/7486#issuecomment-403117359)

Gnawing answered 5/1, 2023 at 16:52 Comment(0)
E
0

I solved the issue by uninstalling the Nuget package Microsoft Entity Framework Core and installing Entity.Framework.Core.Sqlite.Design. I don't know why it solved the issue but the error is gone, I'm happy and that's all that matters.

Enthymeme answered 17/9, 2021 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.