I am building MVC 4 application for some kind of web store. This is first time for me to do anything with ASP.NET so I spent some time reading about whole idea of mvc pattern, and how it is implemented in latest version.
I understood that I need to write Model for data, and I decided to do Code-first approach.
Also I like to different classes move in different files. And also different parts in different classes.
Now I not sure how should I organize model classes. When I make project with “Internet Application” template, I already get AccountModel with user information. It does not sound right for me that I should put information about products in that model. But if I make separate model I will need some kind of connection between this 2 models and I not sure how to make it.
Or should I put whole db in one model?
I would recommend putting everything into one Model, if it’s possible.
Here’s a couple of examples, from the code-behind point-of-view and databases:
Most of the time I’ve only created a single data context, since multiple ones weren’t logical. Why have multiple data contexts, if you only have a single database?
To answer your question: I’m not sure how complex this “web store” will be, but I’d advise to create a single Model. You can always move things around later, if necessary.