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 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


Fabio Silva LimaRank #750 · 3.1K reputationPosted Dec 12, 2016, 12:18 AM EST
MayankRank #4,018 · 371 reputationPosted Dec 12, 2016, 2:35 AM EST
If this resolve your issue then please mark as answer.
Manav PandyaRank #166 · 14.3K reputationPosted Dec 12, 2016, 3:44 AM EST
MayankRank #4,018 · 371 reputationPosted Dec 12, 2016, 4:16 AM EST
I have done the same without edmx.
It is working properly.
Issue is related to edmx only.
Please delete the table from the EDMX and re-add it.
Manav PandyaRank #166 · 14.3K reputationPosted Dec 12, 2016, 4:19 AM EST
MayankRank #4,018 · 371 reputationPosted Dec 12, 2016, 4:22 AM EST
Salman BegRank #284 · 8.8K reputationPosted Dec 12, 2016, 12:24 AM EST