Is EntityFramework available for Windows 8 Store Apps?

狂风中的少年 提交于 2019-12-09 08:36:35

问题


Is EntityFramework available for Windows 8 Store Apps?

I'm using Visual Studio 2012 Express for Windows 8. I'm starting to wonder because I can't make it work.

I installed the Entity Framework package from NuGet I added System.Data.Entity and System.Data.Design to the project

But no matter what I do, DbContext isn't recognized...

Any ideas?

EDIT:

EntityFramework isn't available for Windows Store Apps. I don't understand Microsoft position on this, they suck.

The other solution is to use SQLite but it's not ORM. So what's the point?


回答1:


As far as I know, Windows 8 Store Apps target WinRT (Windows Runtime).

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.

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 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.

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.

Otherwise, you'll need to use a local database storage like SQLite or XML.




回答2:


Entity Framework is not available for Windows 8 store apps. This is due to the fact that windows store apps run in a sandbox and will not be able to use normal database. You can use SQLite for this or have XML / JSon as source which you can deploy in IsolatedStorage of the app on first start of the app.




回答3:


No it's not available. You may use SQLite, this HowTo was very helpful for me. Works great!




回答4:


For the record: The answer is not and the turnaround is to create a web service or use a cloud service. SqlLite is fine for store local (single user) information but nothing more.

About this matter, not all, but most connections to the database are done via a socket connection. So its possible to connect to some database and still keeping the application in a sandbox. However, the intentions of MS is clear : cloud or bust. So MS is saying that its best to connect to a web service (another a socket connection) that its inefficient (and risky) rather to use a direct connection.

Windows Store Apps is simply inferior.

And for adding insult over injury, MS wants to cut some earning from our software.

I really tried to like WinRT (now UWP) but its impossible. And during this 3 years, things aren't changed a bit.



来源:https://stackoverflow.com/questions/15335601/is-entityframework-available-for-windows-8-store-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!