For adding new objects to the Entity Set, you need to create an instance of an Entity type and add the object to the object context.
public bool StudentDetail(StudentDetail objstudetail)
{
StudentDetail studetail = new StudentDetail();
studetail.ID = objstudetail.ID;
studetail.Name = objstudetail.Name;
studetail.Age = objstudetail.Age;
studetail.Address = objstudetail.Address;
studetail.City = objstudetail.City;
try
{
using (DBEntities context = new DBEntities())
{
context.studetails.AddObject(studetail);
context.SaveChanges();
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
Wednesday, August 14, 2013
Home »
Entity Framework
» Add new record in database usinbg Entity Framework/Entity Framework - Inserting Data to Database
0 comments:
Post a Comment