2

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
  • I'd really like to do this as well, but haven't seen a clean way yet. work with an in-memory context, and then when needed, write evetything out to a data file. For use with a thick client app that uses "files" to save and reload data, and where a db is way overkill. Commented Jun 2, 2012 at 20:20

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

4 Comments

In my case the conceptual model is always relational, but the backend storage may or may not be relational. Depending on the specific implementation or connection, it may be SQL, it may be Xml, it may be a custom flat file, or it may be just a temporary collection of objects in memory.
Thanks for the links... I'll look over them.
After going down this road for a while, I think you're correct... EF is not a good fit. Thanks for the advice.
I'd like to know what might be a suitale replacement? Im so tired of using datasets for this...
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.