See the following Steps:
Step 1: Open Visual Studio 2010, Go to the New Project, then Visual C#, Web and select ASP.NET MVC Web Application. After that click OK.

Step 2: After clicking OK, new ASP.NET MVC5 project window will open and there you have you chose MVC and press OK.

Step 3: After clicking OK, you will see something like the following image in your Solution Explorer. You need to look out for Model, Controller and View folders that are the main files in MVC, others are too but these are main files.

Database chamber:
Step 4: Right click on your Project, Add New Item, SQL Server Database and add it. Go to your Database, resides in Server Explorer [Database.mdf], we will create a table Student. Go to the Student Table and Add New table. Design your table like the following:

Show Table Data:

In Model
Step 5: Right Click on Models, Add New Item, then Add ADO.NET Entity Data Model and Name it Student.edmx, then ADD it.





In Controller
Step 6: Right Click on Controller and Add Controller. You have to chose MVC5 Controller with Views using Entity Framework and ADD it.

Fill up the necessary model name and data context class name and add it, when you hit add, you will see, under view folder there is another folder created name – “Student” and four method created to perform – “CRUD”.

Inside View Folder-

Student Controller.cs:
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.Entity;
- using System.Linq;
- using System.Net;
- using System.Web;
- using System.Web.Mvc;
- using CRUDOperation.Models;
- namespace CRUDOperation.Controllers
- {
- public class StudentsController : Controller
- {
- private mynewdataEntities db = new mynewdataEntities();
- // GET: Students
- public ActionResult Index()
- {
- return View(db.Students.ToList());
- }
- // GET: Students/Details/5
- public ActionResult Details(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Student student = db.Students.Find(id);
- if (student == null)
- {
- return HttpNotFound();
- }
- return View(student);
- }
- // GET: Students/Create
- public ActionResult Create()
- {
- return View();
- }
- // POST: Students/Create
- // To protect from overposting attacks, please enable the specific properties you want to bind to, for
- // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Create([Bind(Include = "ID,Name,City")] Student student)
- {
- if (ModelState.IsValid)
- {
- db.Students.Add(student);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(student);
- }
- // GET: Students/Edit/5
- public ActionResult Edit(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Student student = db.Students.Find(id);
- if (student == null)
- {
- return HttpNotFound();
- }
- return View(student);
- }
- // POST: Students/Edit/5
- // To protect from overposting attacks, please enable the specific properties you want to bind to, for
- // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "ID,Name,City")] Student student)
- {
- if (ModelState.IsValid)
- {
- db.Entry(student).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(student);
- }
- // GET: Students/Delete/5
- public ActionResult Delete(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Student student = db.Students.Find(id);
- if (student == null)
- {
- return HttpNotFound();
- }
- return View(student);
- }
- // POST: Students/Delete/5
- [HttpPost, ActionName("Delete")]
- [ValidateAntiForgeryToken]
- public ActionResult DeleteConfirmed(int id)
- {
- Student student = db.Students.Find(id);
- db.Students.Remove(student);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- }
- }
Here you can create, edit , delete or update the data – Try it.


Rahul SoniPosted Mar 11, 2019, 4:38 AM
Thanks Nilesh your MVC step is really good for beginner. but Database chamber need to describe more for new comer .
Hitesh WedwaniPosted Jul 31, 2018, 6:04 AM
Good One !!!!!!!
Arul RPosted Oct 28, 2015, 5:31 AM
Good one !!!
Rupali ShindePosted Oct 15, 2015, 12:28 AM
good job
Sibeesh VenuPosted Oct 6, 2015, 9:46 AM
Nice Share
Harshad PansuriyaPosted Oct 6, 2015, 8:52 AM
Nice one
Santhakumar MunuswamyPosted Oct 5, 2015, 11:51 PM
Nice Share
sreenivasa kPosted Oct 5, 2015, 11:39 PM
excellent
RakeshPosted Oct 5, 2015, 1:21 PM
Good share
Shridhar SharmaPosted Oct 5, 2015, 12:57 PM
nice demo
Kameshwar RoyPosted Oct 5, 2015, 7:03 AM
Nice
Ankit BansalPosted Oct 5, 2015, 5:55 AM
Nice..thanks for sharing with us..
Gowtham RajamanickamPosted Oct 5, 2015, 4:57 AM
useful....
Rajeesh MenothPosted Oct 5, 2015, 4:55 AM
Nice One...
Harshad PansuriyaPosted Oct 5, 2015, 4:55 AM
Nice one