Reputation: 5550
I am using Visual Studio 2010 with c# 4.01, MVC3 and Entity Framework 5.
I want to use a read-only text file as an EF data-source. My simple data structure is:
public class FlatFile
{
public string Caption {get; set; }
public string Filename {get; set; }
}
I seem to have a block as to how to set this up with EF. Help! and thanks !
Upvotes: 1
Views: 4579
Reputation: 6294
To sum up most of whats in the comments above: EF is designed to query against databases and return subsets of the data that is needed. Simply serializing and de-serializing your entire dataset is all you will really need if you want to back your data into a flat file. This can be a dangerous path to take if your dataset becomes too large. There are also little tidbits that must be addressed to make sure you are thread safe for your web environment.
However, it seems like you need a stepping stone for your development, starting simply and eventual upgrading to a 'real' database, without having to rewrite a bunch of code. Since you mentioned MVC3, I would highly recommend checking out an IOC/DI tool like Ninject. This way you can define the interfaces needed and simply swap out the implementation when you are ready. I would also recommend trying Code First as opposed to a flat file, by default it will use a local data store and may provide a smoother transition to a database later.
Upvotes: 2