在Microsoft.EntityFrameworkCore.Tool的DbContextOptionsBuilder类中缺少UseSqlite的定义

时间:2017-11-19 15:49:51

标签: sqlite uwp entity-framework-core uwp-xaml windows-10-mobile

我正在尝试使用UWP编写一个简单的手机应用程序,它将Windows文件夹位置的图像插入SQLite上的表格并在Windows手机上查看。

我在technet论坛上发现了这篇文章,我将其用于参考:

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

按照说明操作时,我遇到了安装软件包Microsoft.EntityFrameworkCore.Tools(最新的稳定版本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

同样的问题也出现在以前的版本(2.0.0)中,但下一个以前的版本(1.1.4)已成功安装。

但是,我发现代码“PictureAppContext”类中使用的“DbContextOptionsBuilder”类无法识别方法“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

任何人都知道如何解决这个问题?

谢谢!

2 个答案:

答案 0 :(得分:8)

我使用dotnet sdk 2.1.1遇到了同样的问题,它应该将所有基本依赖项都包装在Any API service that returns long-running operations should implement the Operations interface so developers can have a consistent client experience.中。我需要做的就是在项目目录(包含Program.cs,Startup.cs和 .csproj文件)

答案 1 :(得分:0)

对于.NET 5,我必须安装软件包Microsoft.EntityFrameworkCore.Sqlite.Core

检查link