Entity Framework 7目前提供 Beta 版和 this article表示可以(将?)在 Xamarin 项目中使用 Entity Framework 7。
但是,当我尝试使用 NuGet 安装它时:
Install-Package EntityFramework.SQLite –Pre
它会失败:
Install-Package : Could not install package 'EntityFramework.Sqlite 7.0.0-beta6'. You are trying to install this package into a
project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or
content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package EntityFramework.SQLite –Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
有没有办法在 Xamarin 项目中使用 Entity Framework ,或者我必须坚持使用 sqlite-net ?
编辑:正如@Daniel Luberda 所建议的,我只是尝试将 Entity Framework 安装到从 Xamarin.Forms 共享项目模板创建的项目中,但这失败并出现以下错误:
Install-Package : Could not install package 'System.Runtime 4.0.20-beta-23109'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v5.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package EntityFramework.SQLite –Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Windows Phone项目和iOS项目也是如此。
最佳答案
我刚刚查看了 EF7 nupkg,看起来它们没有特定于平台的编译。
roadmap 也证实了这一点,它说:
The November release candidate (RC1) will be a supported and production ready cross-platform release. Depending on feedback from RC1 we will ship additional release candidates as necessary.
RC1 目前计划于 2015 年 11 月举行。在使用 nuget 包之前,您可能需要等待该版本。
与此同时...您可以尝试从 github 构建源代码以 PCL 78 为目标,但我怀疑这不值得你花时间。
在任何一种情况下,如果您遵循良好的 MVVM 实践,您应该能够构建应用的重要部分并根据需要替换数据接口(interface)。
关于c# - Xamarin.Forms 中的 Entity Framework 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32213997/