作者:清-新花曼的日子 | 来源:互联网 | 2023-01-08 11:45
如何解决《在Microsoft.EntityFrameworkCore.Tool的DbContextOptionsBuilder类中缺少UseSqlite的定义》经验,为你挑选了1个好方法。
我正在尝试使用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
谁知道如何解决这个问题?
谢谢!
1> Oge Nwike..:
我使用dotnet sdk 2.1.1遇到了同样的问题,它应该包含所有基本依赖项Microsoft.AspnetCore.App
.我需要做的就是dotnet add package Microsoft.EntityFrameworkCore.Sqlite
在项目目录的终端窗口中运行(包含Program.cs,Startup.cs和.csproj文件的目录)