views:

2781

answers:

5

Can someone point me to a good tutorial explaining the Entity Framework using an XML file instead of a database? I have seen some good tutorials with SQL databases, but I can't make the leap to an XML file.

Thanks!

A: 

I don't think that's really possible.

From MSDN (emphasis mine):

The ADO.NET Entity Framework is designed to enable developers to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema.

bdukes
+4  A: 

Entity Framework itself is provider-based, and is designed to operate over a relational database. If you really wanted to, you could write your own provider for EF that reads from/writes to an xml file, but it would be a huge amount of work.

I expect you should really be looking at one of:

  • LINQ-to-XML
  • XML (de)serialization
  • XPath/XQuery
  • XSLT

Entity Framework doesn't have a natural fit in this scenario.

Marc Gravell
+1  A: 

Linq to XML isn't all that much actually. I'd go with a serializable solution instead.

mhenrixon
+1  A: 

I like LINQ to XSD: http://linqtoxsd.codeplex.com/

It is basically LINQ to XML with some classes derived from the XSD to ensure it fits the schema...

Kearns
i've found this tool very useful - however the context menu doesn't seem to show up in vs 2010..
benpage
A: 

You can use an oledb connection together with a FORXML command... but you will not have all functionality that is available with other providers...

bakopanos costas