Here in the internet have a lot tutorial introduction about create code first asp mvc application, but in the real life world the database always aready is exsiting. I am not mvc experter, I am fresher now. It took me a while to get the basic struction a while.So I like to write it down wish this could help some people like me struggling in the beginning.
OK, let me asume that we are going to create a online store ecormmerce website.
Way one: basic struction
Then you create a new MVC project through VS2013, first thing is add a connection string to your root web.config file.
Models is nothing just class file. You map your table to class file, then when you create a controller you could select strongly type.
finally is the Add one line to Global.asax to stop populater some seed data
See the null meaning don’t popular seed data.
Way two: basic struction(Models is another project)
I won’t talk about the controller or the views. But Models could anything, Web services, WCF and don’t sit in your project, the model is not neccessary sit in your project.So your project only have controller and Views, but the Models is independent. Here is a simple practise I did in my Demo struction is like this:
Way three: basic struction(Model is your entity Framework)