Associate
- Joined
- 2 Sep 2007
- Posts
- 1,997
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: -
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?
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: