0

I'm looking for more information on creating ASP.NET MVC 4 Models that do not use a database as the back end. I'd like to use a .CSV file for example. For right now this is a learning exercise to better understand the concepts, however I will eventually be moving to a database back end although it will not be the Entity Framework.

All I'm looking for are a few posts or tutorials that address models without using a database. I'll take it from there.

I've searched and found a similar post but I didn't feel as though it was fully answered. Asp.net mvc models without databases/framework

Community
  • 1
  • 1
Matt G.
  • 15
  • 9
  • It's the same thing. csv is a sort of database. – the_lotus Sep 13 '13 at 14:48
  • 1
    Your question is vague. Models aren't coupled to data persistence mechanism, they are representations of concepts that exist in your business domain. You might want to look at the Repository pattern, which is more concerned with persistence, and allows you to persist your model information into databases, CSV, XML, etc... – Mister Epic Sep 13 '13 at 14:49
  • @ChrisHardie I guess its vague because I don't fully understand models. I "get" the concept but I've not worked with MVC so its uncharted territory for me. What I'm doing right now isn't a production project, its a project to learn MVC. Perhaps if I had a better understanding my question would have been so vague. :-\ I do appreciate your input, thanks much! – Matt G. Sep 13 '13 at 15:20
  • @the_lotus technically it is similar in concept, both are datastores. – Matt G. Sep 13 '13 at 15:21
  • There's very little to "understand" about Models. They're just classes that represent your data. That's it. They aren't tied to a database, or a file or anything. If you understand how classes work, you understand all you need to know about models. – Erik Funkenbusch Sep 14 '13 at 04:44

1 Answers1

1

With flat files you're always going to come into trouble if you need relations between different entities e.g. Authors, and Books. But I assume you know that. There's more on this discussion here:

Flat File Database Example

Try searching for 'flat file database .net mvc' or similar.

This person has had a go with a text file that is pipe-delimited but could easily be adjusted for comma-delimited (they use webforms but most of the code is identical to what you'd do in MVC):

http://www.nullskull.com/a/1520/flat-file-database-with-linq-and-aspnet-jquery-page-methods.aspx

You might also like to try a JSON format file which lends itself to NoSQL databases like MongoDB and obviously works well with client-side Javascript coding.

Community
  • 1
  • 1
rwalter
  • 891
  • 1
  • 7
  • 19
  • Yup, I know that I should use some form a database as a back end and what I'm losing (or getting into) if I continue using flat files to store information, especially if the application continues to grow. I'd love to use MongoDB however currently that is not an option. I'm just plunking around right now, trying to gain a better understanding of how it all works. (I'm coming from a php/mysql world of which I've been in for the past 10 years). – Matt G. Sep 13 '13 at 15:07
  • Thanks! I'll get there eventually. – Matt G. Sep 13 '13 at 15:22