Building your first ASP.NET MVC 4 application in VS 2012 – using MVC Scaffolding

Previously I wrote a post about creating a simple ASP.NET MVC 4 application. I have told you, that it is so simple. Today you will see that it can be easier with MVC scaffolding.

 

1. Open Visual Studio 2012

2. File/New/Project -> select Web/ASP.NET MVC 4 Web Application. Name it MvcCars.

3. When new window appears, please select a template as Internet Application and the vie engine as Razor. For this example, please do not select Create a unit test project.

4. Confirm

Your project structure should look like this:

1

 

We will start from creating a new model class. To do this, please right click on folder Models, select Add->New Item and choose Class. Name it as Car.cs – it is our first POCO in a project. The next thing is to add primitive properties inside of a class as below:

2

 

Ok. Now you can say that it looks exactly the same as in https://mjedrzejewski.wordpress.com/2013/09/09/building-your-first-asp-net-mvc-4-application-in-vs-2012/

Yes. It does. But the the fun is just getting started.

Go to the Tools/Library Package Manager and select Package Console Manager. You need to write as input PM> install-package MvcScaffolding and click Enter. MVC scaffolding package will start installing.

Ok, what’s next?

Go to the Package Console Manager and write as input PM> Scaffold Controller Car 

Wait until everything is done. You will see that all: Controller with CRUD methods, Views for Cars and Context class appear! Without writing any line of code, after you have prepared the model class. Your project structure should be similar to the previous one:

1

 

Of course, there are a lot of other advantages of using MVC Scaffolding, such as: adding Interfaces etc.

Isn’t this great?

 

 

 

Jedna uwaga do wpisu “Building your first ASP.NET MVC 4 application in VS 2012 – using MVC Scaffolding

Zostaw komentarz

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj /  Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj /  Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj /  Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj /  Zmień )

Connecting to %s