Manav Pandya

Manav Pandya

  • NA
  • 19.9k
  • 2.3m

Poperty Error in MVC

Dec 12 2016 5:03 AM
Hello
Today i have faced this error :
 

The 'phone' property on 'Student' could not be set to a 'System.String' value. You must set this property to a non-null value of type 'System.Int32'.

 And my Model class is : Student
 
[Table("tblStudent")]
public class Student
{
public int StudentId { get; set; }
public string name { get; set; }
public string email { get; set; }
public int phone { get; set; }
}
 
 
 My Context class  : StudentContext
 
public class StudentContext: DbContext
{
public DbSet<Student> Students { get;set; }
}
 
My StudentController is shown below :
 
public ActionResult Index(int id)
{
StudentContext stud = new StudentContext();
Student ss=stud.Students.Single(stu => stu.StudentId == id );
return View(ss);
}
Help me guys in that please soon 
 

Answers (7)