Thomas Henson

  • Data Engineering Courses
    • Installing and Configuring Splunk
    • Implementing Neural Networks with TFLearn
    • Hortonworks Getting Started
    • Analyzing Machine Data with Splunk
    • Pig Latin Getting Started Course
    • HDFS Getting Started Course
    • Enterprise Skills in Hortonworks Data Platform
  • Pig Eval Series
  • About
  • Big Data Big Questions

Scaffolding with MVC 4.0

January 28, 2014 by Thomas Henson

How important is it to automate your development?

Very important! This is one trait that separates good developers from great developers. The less time you spend writing repetitive code the more time and energy  you have to solve the challenge problems.

If you have ever used the MVC framework in your development you know the routine you create a model with your Getters and Setters, then your controller so you can access the data and finally the view for each page so the user can use your app. This assumes you already have your database in place if not you need to create that as well. With Scaffolding you can create all of these at the same time and move on to solving the big issues.

Scaffolding is an outline auto-generated from the application’s Model. By using scaffolding for a Web Application we can set up our Model and begin using our application. The application will be very basic but fully testable in a matter of minutes. Both C# and VB support scaffolding and it is fully shipped with Visual Studio 2012.

Scaffolding with MVC 4.0 Tutorial

For this example I will use an application I am creating for tracking books. My development environment is Visual Studio 2012 Express with the C# MVC 4.0 template.

  1.  Add a new model with your Getters and Setters declared. In my example I have 5 field for now that I want to track an ID, Book Name, Date Read, Review and Author
  2. Next move to the Solution Expl0rer and right click on your Controllers folder then select add new Controller
  3. Visual Studio will open up a dialog with five data fields:
    1. Controller Name – This is the name of your Controller BooksController
    2. Template –  Specifies the template Visual Studio will use to populate your Controller MVC controller with read/write actions and views, using Entity Framework
    3. Model Class – The Class name and Model to populate template data Book (BookTracker.Models)
    4. Data Context Class – The Database Connection String named in your Web.Config file BookContext (BookTracker.Models)
    5. Views – Templates for the Views, Razor is the default Razor (CSHTML)
  4. After clicking the Add button Visual Studio will automatically populate the Controller and corresponding Views.

Wow in just 4 quick steps Visual Studio saved us at least 20-40 minutes of setting up our Controllers and Views for edit, create, details, delete, and index for my application. So basically with using the MVC template in Visual Studio 2012 and Entity Framework Scaffolding we have created a CRUD application in about 5 minutes.

Filed Under: MVC Tagged With: ASP.NET, MVC 4.0, Web Development

Subscribe to Newsletter

Archives

  • February 2021 (2)
  • January 2021 (5)
  • May 2020 (1)
  • January 2020 (1)
  • November 2019 (1)
  • October 2019 (9)
  • July 2019 (7)
  • June 2019 (8)
  • May 2019 (4)
  • April 2019 (1)
  • February 2019 (1)
  • January 2019 (2)
  • September 2018 (1)
  • August 2018 (1)
  • July 2018 (3)
  • June 2018 (6)
  • May 2018 (5)
  • April 2018 (2)
  • March 2018 (1)
  • February 2018 (4)
  • January 2018 (6)
  • December 2017 (5)
  • November 2017 (5)
  • October 2017 (3)
  • September 2017 (6)
  • August 2017 (2)
  • July 2017 (6)
  • June 2017 (5)
  • May 2017 (6)
  • April 2017 (1)
  • March 2017 (2)
  • February 2017 (1)
  • January 2017 (1)
  • December 2016 (6)
  • November 2016 (6)
  • October 2016 (1)
  • September 2016 (1)
  • August 2016 (1)
  • July 2016 (1)
  • June 2016 (2)
  • March 2016 (1)
  • February 2016 (1)
  • January 2016 (1)
  • December 2015 (1)
  • November 2015 (1)
  • September 2015 (1)
  • August 2015 (1)
  • July 2015 (2)
  • June 2015 (1)
  • May 2015 (4)
  • April 2015 (2)
  • March 2015 (1)
  • February 2015 (5)
  • January 2015 (7)
  • December 2014 (3)
  • November 2014 (4)
  • October 2014 (1)
  • May 2014 (1)
  • March 2014 (3)
  • February 2014 (3)
  • January 2014 (1)
  • September 2013 (3)
  • October 2012 (1)
  • August 2012 (2)
  • May 2012 (1)
  • April 2012 (1)
  • February 2012 (2)
  • December 2011 (1)
  • September 2011 (2)

Tags

Agile AI Apache Pig Apache Pig Latin Apache Pig Tutorial ASP.NET AWS Big Data Big Data Big Questions Book Review Books Data Analytics Data Engineer Data Engineers Data Science Deep Learning DynamoDB Hadoop Hadoop Distributed File System Hadoop Pig HBase HDFS IoT Isilon Isilon Quick Tips Learn Hadoop Machine Learning Machine Learning Engineer Management Motivation MVC NoSQL OneFS Pig Latin Pluralsight Project Management Python Quick Tip quick tips Scrum Splunk Streaming Analytics Tensorflow Tutorial Unstructured Data

Follow me on Twitter

My Tweets

Recent Posts

  • Tips & Tricks for Studying Machine Learning Projects
  • Getting Started as Big Data Product Marketing Manager
  • What is a Chief Data Officer?
  • What is an Industrial IoT Engineer with Derek Morgan
  • Ultimate List of Tensorflow Resources for Machine Learning Engineers

Copyright © 2023 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in