How to use Entity Framework 4.0 with Xml or in-memory Storage (non-SQL)

我只是一个虾纸丫 提交于 2019-12-23 01:04:41

问题


How do I specify Xml or just in-memory storge for Entity Framework models? The connection string requires a provider (usually a SQL provider string). But it won't let me omit the provider.

I realize I could completely throw away the designer generated objects and go pure POCO, but then I'd have to implement my own serialization layer (could do that, but it's overkill for the tiny project I'm working on).

Is there built-in support in EF 4.0 for this that I'm missing or do I just need to go the pure POCO route and discard the designer experience entirely :(


回答1:


If you want to store data in Xml or memory you should probably not use EF. EF is designed to work with relational databases.

See also: Entity Framework with XML Files

For storing data in memory use System.Runtime.Caching

For storing data in xml files see: http://msdotnetsupport.blogspot.com/2007/04/reading-and-writing-xml-files-using-c.html




回答2:


This is a good way to do what you're probably thinking.

Use a SQLite db as the backing store. That way you get you're single local file and you can still use almost all of EF.

http://dotnet.dzone.com/news/sqlite-entity-framework-4



来源:https://stackoverflow.com/questions/4017332/how-to-use-entity-framework-4-0-with-xml-or-in-memory-storage-non-sql

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