简体   繁体   English

Xamarin.Forms中的实体框架7

[英]Entity Framework 7 in Xamarin.Forms

Entity Framework 7 is currently available as a Beta version and this article states that it is (will be?) possible to use Entity Framework 7 in Xamarin projects. 实体框架7目前作为Beta版本提供, 本文指出在Xamarin项目中使用Entity Framework 7是可能的(将会是?)。

However, when I try to install it using NuGet: 但是,当我尝试使用NuGet安装它时:

Install-Package EntityFramework.SQLite –Pre

It will fail: 它会失败:

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

Is there any way to use Entity Framework in a Xamarin project or will I have to stick with sqlite-net ? 有没有办法在Xamarin项目中使用Entity Framework,还是我必须坚持使用sqlite-net

Edit: As @Daniel Luberda suggested, I just tried installing Entity Framework into a project created from the Xamarin.Forms Shared Project template, but this fails with the following error: 编辑:正如@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

The same is true with the Windows Phone project and the iOS project. Windows Phone项目和iOS项目也是如此。

I just looked at the EF7 nupkg and it doesn't look like they have platform-specific compilations. 我只看了EF7 nupkg,看起来他们没有特定于平台的编译。

This is also confirmed by the roadmap , which says: 路线图也证实了这一点,该路线图说:

The November release candidate (RC1) will be a supported and production ready cross-platform release. 11月发布的候选版本(RC1)将是一个支持和生产就绪的跨平台版本。 Depending on feedback from RC1 we will ship additional release candidates as necessary. 根据RC1的反馈,我们将根据需要发布其他候选版本。

RC1 is currently scheduled for Nov'15. RC1目前定于2015年11月。 Chances are you'll need to wait for that release before you can use the nuget package. 在使用nuget软件包之前,您可能需要等待该版本。

In the meanwhile... you could try building the source code from github to target PCL 78, but I suspect it won't be worth your time. 同时......你可以尝试从github构建源代码到目标PCL 78,但我怀疑它不值得你的时间。

In either case if you follow good MVVM practices you should be able to build substantial parts of your app and replace the data interface as needed. 在任何一种情况下,如果您遵循良好的MVVM实践,您应该能够构建应用程序的大部分内容并根据需要替换数据接口。

This was asked to be implemented in EF 7, or now EF core 1.0, but no clear road map for it, maybe if more people ask for it in their, it will urge MS to make it: 这被要求在EF 7或现在的EF核心1.0中实施,但没有明确的路线图,也许如果有更多的人在他们的要求,它会敦促MS做到:

EF 7 Xamarin.Forms support EF 7 Xamarin.Forms支持

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM