Introduction

Using MVC, Entity Framework, ASP.NET Scaffolding you can create a web application that stores your information. This demo shows you how to create a ASP.NET 5 web application with MVC and Entity Framework 7.

 

STEP 1 - Create ASP.NET 5 Web Application

  • Open Visual Studio 2015 and create a new project of type ASP.NET 5 Web Application.
  • On this project create a solution called Demo.

  • Press OK, and a new screen will appear, with several options of template to use on our project.
  • Select the option MVC.

After selection of our template, your first web application using ASP.NET 5 is created.

  

 

STEP 2 - Create Data Model

After we have our web application created, we need to create our data model.

For that, select the option Add New Item on solution and choose the option Class. Create the class like the one on the image above.

 

STEP 3 - Scaffolding

This could be made easily using the Scaffolding functionality.

On the solution on the top of controller folder, select the option Add New Scaffold Item.

On the new screen, select the option MVC 6 Controller with views using Entity Framework.

 

Select the name of the controller, class model and data context class.

  

The new controllers and views associated, was created with success.

  

 

STEP 4 - Change Menu Layout

To test the two tables, we can add two new entries on the web application menu.

 

STEP 5 - Run Application

Press the F5 button to run the web application.

The new entities appear on the menu.

  

Press the option Cars to see our entity in action

An message error will appear saying that the entity doesn't exist on internal database and that we need to create it using some commands on package manager console.

  

Execute the commands like on the image above and try again.

And that's it! Now its working.

Resource:

Code - https://code.msdn.microsoft.com/ASPNET-5-Create-Web-b8a44cce