Introduction

In my last article series I have explained how we can perform select, update and insert using scaffolding with entity framework. In this article I am going to explain the Scaffolding Detail option.

In the following screen you will the Detail link:-

		
		MVC Scaffolding using EF
		
Figure 1

So first add Detail action in Home Controller which is taking the id as parameter which is bound on actionlink.

		
		public ActionResult Details(int id)
        {

            return View();
        
        }

		
		

Now add view for this Details screen by right clicking on Details and select Add view and you will get following screen:-

		
		Scaffolding Details option using EF
		
		Figure 2
		
		

When you clicked on add button a Details.cshtml view will be created. Now select the data for corresponding id in Details action and pass it to the view.

Controller Code

		
		public ActionResult Details(int id)
        {
            scaff_efEntities scaff = new scaff_efEntities();
            student stu = scaff.students.Find(id);
            return View(stu);
        
        }

		
		

Now execute this code and click on detail actionlink and you will get following window:-

		
		MVC Scaffolding Details option 
		
		Figure 3
		
		

Email Address

For any query you can mail me at Malhotra.isha3388@gmail.com.