ASP.NET MVC Question

Associate
Joined
2 Sep 2007
Posts
1,975
Just started using MVC. Just wondered what the norm / best practice is with splitting the data model, etc. This is what I've done so far.

In my solution I have a MVC Project and a class library project which contains my Entity Framework model - Database First. At the moment I'm using a controller to save some data to the database: -

Code:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
//a load of code here to setup the blob class
//........
//create context
var context = new LIVEEntities();
context.BLOBS.Add(blob);
context.SaveChanges();
}

I assume this is bad practice as I've read that controller code should be kept a bare minimum. Where is the best place to do this? In the class library or somewhere else?
 
Last edited:
Associate
OP
Joined
2 Sep 2007
Posts
1,975
Hi Gambisk

Thanks for that link. It's a small project at the moment but it could become a large project. At the moment I don't have any models in my model folder which seems unusual when you see most examples on the web do.
 
Associate
OP
Joined
2 Sep 2007
Posts
1,975
It took me a while to figure out the razor engine. Once I got my head around it then it comes as second nature.

The joys of not having to fight against the page life cycle is so rewarding.

What specifically are you struggling with at the moment?

If you see my other post I can't get my head around something simple like that. Basically, a textbox where a user enters a value and that value is used as a parameter to populate the dropdownlist which is bound to a datasource (entity framework).
 
Back
Top Bottom