- Open Visual studio
- Click on “File”>New>Project>Visual c#>Web> then provide your project name> then select “ok”> then click “MVC”>ok.
- Go to “HomeController” and delete the default “ActionMethod” as like video.
- Go to “Views”>”Home” folder and delete default views.
- Create an Action method name “Index” into “HomeController”.
public ActionResult Index()
ContactDBEntities db = new ContactDBEntities();
ViewBag.ItemData = db.tblAddresses.ToList();
- We have already created Database(We were provide you this Database with project, the folder name “DataBase” into project.click to download the full project
- Now we will include the created database to ADO.NET Entity Framework.(It’s very easy way to use).
- Right click on folder named “Model”>Add>New Item>ADO.NET Entity DataModel>ok>Generate from database>next>New connection>Provide your SQL Server name to “Server name” textfield>Select database from “database name”>ok>next
- Expand “table”>expand “dbo”>select your created table>“finish
@foreach (var data in ViewBag.ItemData)
Now run the project and you will only be able to see the list of data from database.