EntityFramework 是否可用于 Windows 8 商店应用程序? [英] Is EntityFramework available for Windows 8 Store Apps?
问题描述
EntityFramework 是否可用于 Windows 8 商店应用程序?
Is EntityFramework available for Windows 8 Store Apps?
我使用的是适用于 Windows 8 的 Visual Studio 2012 Express.我开始怀疑,因为我无法让它发挥作用.
I'm using Visual Studio 2012 Express for Windows 8. I'm starting to wonder because I can't make it work.
我从 NuGet 安装了实体框架包我在项目中添加了 System.Data.Entity 和 System.Data.Design
I installed the Entity Framework package from NuGet I added System.Data.Entity and System.Data.Design to the project
但无论我做什么,都无法识别 DbContext...
But no matter what I do, DbContext isn't recognized...
有什么想法吗?
EntityFramework 不适用于 Windows 应用商店应用.我不明白微软在这方面的立场,他们很糟糕.
EntityFramework isn't available for Windows Store Apps. I don't understand Microsoft position on this, they suck.
另一种解决方案是使用 SQLite,但它不是 ORM.那么重点是什么?
The other solution is to use SQLite but it's not ORM. So what's the point?
推荐答案
据我所知,Windows 8 Store Apps 面向 WinRT (Windows Runtime).
As far as I know, Windows 8 Store Apps target WinRT (Windows Runtime).
出于这个原因,因为可以使用 C# 来定位 WinRT,并且有很多来自 .NET Framework 的类在 WinRT 中具有匹配项,所以大多数不使用特定库的可用代码库也可以在 Windows 8 商店应用程序上运行.
For that reason, because WinRT can be targeted using C# and there're a lot of classes from .NET Framework having a match in WinRT, most of available code base not using very specific libraries may work also on Windows 8 Store Apps.
WinRT 中有很多不可用的东西.例如,实体框架构建在 ADO.NET 之上,而这在 WinRT 上不可用.
There're a lot of things unavailable in WinRT. For example, Entity Framework is built on top of ADO.NET and this isn't available on WinRT.
Visual Studio 足够智能可以隐藏 WinRT 上不可用的此类和组件,这就是无法在您的 Windows 8 应用商店应用项目中使用实体框架相关类的原因.
Visual Studio is smart enough to hide such classes and components that aren't available on WinRT and this is why Entity Framework related classes can't be used in your Windows 8 Store App project.
为了使用实体框架,您需要创建一个 RESTful Web API(例如使用 ASP.NET Web API)并通过网络异步访问数据层.
In order to use Entity Framework, you'll need to create a RESTful Web API (for example using ASP.NET Web API) and access the data layer asynchronously over the wire.
否则,您将需要使用 SQLite 或 XML 等本地数据库存储.
Otherwise, you'll need to use a local database storage like SQLite or XML.
这篇关于EntityFramework 是否可用于 Windows 8 商店应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!