Entity Framework with text files (no database!)

2019-02-24 01:10发布

问题:

I'm used to Forms and DataSets but now I'm trying out WPF and the Entity Framework. My goal is to fill a DataGrid in WPF with the use of the Entity Framework. However, I do NOT have a database! I have simple text files with data that I have to parse to fill my Entities.

However, I get errors like "Entity type 'TableName' is not mapped." and crashes like that I don't have a connection string.

Is it possible to use the Entity Framework without a database? Or do I have to go back to use a DataSet?

回答1:

Interesting idea. Microsoft's quite enthusiastic that in theory you can write an EF provider that maps to any kind of data store. I've not got experience with one that maps to a text file, but this link suggests that someone's done it with CSV(!): http://social.msdn.microsoft.com/Forums/ar-SA/adodotnetentityframework/thread/a0e9e20f-66d2-447c-8b7e-75de18535e63?persist=True

If you're stuck with using text files though, why not try LINQ to XML?

And: Entity Framework with XML Files