我正在使用MVC4编写网页。我使用实体框架和Visual Studio Express 2012 for web。当我为学生插入代码时,出现问题:实体框架中的AddObject不起作用(MVC 4)
demoMVCEntities db = new demoMVCEntities();
n412_Student _newStudent = new n412_Student();
_newStudent.Student_FirstName = _fname;
_newStudent.Student_LastName = _lname;
_newStudent.Student_Phone = _phone;
_newStudent.Student_Email = _email;
_newStudent.Student_Province = _provinces;
db.n412_Student.AddObject(_newStudent);
AddObject红色下划线。消息错误:
"'System.Data.Entity.DBSet' does not contain a definition for 'AddObject' and no extension method 'AddObject' accepting a first argument of type...."
请帮助我..谢谢..!
非常感谢您! – 2015-04-05 16:30:32
没问题;),如果你认为我的回答帮助你解决了你的问题,请考虑点击复选标记来接受它。这向更广泛的社区表明,您已经找到了解决方案,并为答复者和您自己提供了一些声誉。没有义务这样做。 – octavioccl 2015-04-06 15:35:48