Hi,
I have knowledge about db connectivity for MVC. But i want to know actual process using entity framework. Please suggest best link for learn.
Regards
Hemlata
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Harshad PansuriyaRank #1,124 · 1.6K reputationPosted Sep 1, 2015, 10:39 PM EDT
Francis SusaimichaelRank #466 · 5.4K reputationPosted Sep 2, 2015, 12:15 AM EDT
Shibly Sadik154 reputationPosted Sep 2, 2015, 8:33 AM EDT
Create a model class named Student under Model folder and write the follwing code inside the model:
public class Student
{
public int StudentId {get;set;}
public string Name {get;set;}
public string Roll {get;set;}
public string Dept {get;set;}
}
public class StudentContext:DbContext
{
public DbSet
}
//Add a controller Named StudentController
public class StudentController:Controller
{
StudentContext db=new StudentContext();
public ActionResult AddStudent(Student student)
{
if(ModelState.isValid)
{
db.Students.add(student);
db.SaveChanges();
}
}
}
Now rebuild the project.Open the View folder.Right click on Student Folder.Select Add and then choose View.Give the view name AddStudent.Select Create template.Select model Student and choose database context s StudentContext.Click Add.You are done.Run your project.
This may help you.
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Sep 2, 2015, 11:45 AM EDT