Hi,
Try to use EF code first, it would be much simpler to understand it.
1. Create your solution(ASP>MVC )
2. Download NuGet package in package manager console write the next:
- Install-Package EntityFramework -Version 4.3.1
3) Create you database context class, for example:
public calss StudentContext:DbContext
{
public StudentContext():base("name=ConStringName"){}
public DbSet<student> Students{get;set;}
}</student>
4) Create Student Entity ->
public class Student
{
[System.ComponentModel.DataAnnotations.Key]
public int Id{get;set;}
[Required()]
public string Name {get;set;}
}
5) Create StudentController module and implement Index method in it:
public class StudentController:Controller
{
public ActionResult Index()
{
using(var context=new StudentContext())
{
return View(context.Students.AsEnumerable());
}
}
}
6) the last one all you nedd is to create Index view:
@model IEnumerable<student>
@{
ViewBag.Title="Student index page"
}
<ul>
@{
foreach(var student in Model)
<li>@student.Name</li>
}
</ul>
Hope this will help you!!