Entity Framework Xamarin.Forms 中的 7 个

Entity Framework 7 in Xamarin.Forms

Entity Framework 7 is currently available as a Beta version and 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

WindowsPhone项目和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 实践,您应该能够构建应用的重要部分并根据需要替换数据接口。

这被要求在 EF 7 或现在的 EF core 1.0 中实现,但没有明确的路线图,也许如果更多人要求它,它会敦促 MS 实现它:

EF 7 Xamarin.Forms 支持

https://github.com/aspnet/EntityFramework/issues/4269