Skip to main content

Posts

ASP.NET MVC 5 - Accessing Model's Data from a Controller

Build the application  before going on to the next step. If you don't build the application, you'll get an error adding a controller. 4 In Solution Explorer, right-click the  Controllers  folder and then click  Add , then  Controller . In the  Add Scaffold  dialog box, click  MVC 5 Controller with views, using Entity Framework , and then click  Add . 1 Select  Movie (MvcMovie.Models)  for the Model class. Select  MovieDBContext (MvcMovie.Models)  for the Data context class. For the Controller name enter  MoviesController . The image below shows the completed dialog. 2 Click  Add . (If you get an error, you probably didn't build the application before starting adding the controller.) Visual Studio creates the following files and folders: 2 A MoviesController.cs  file in the  Controllers  folder. A  Views\Movies  folder. Create.cshtml, Delete.cshtml, Details.cshtml, Edit.cshtml , and  Index.cshtml  in the new  Views\Movies  folder. Visual Stud