Reputation: 356
I am using Entity Framework to link my data to asp.net mvc application. The weird part is that I can read the records normally using the below GetALL function but none of the Insert and Delete are working. Is there any reason for that? I am wondering if there is any restriction on the database and how to fix it if any? Note that I am getting no error however it is saying create is successful and delete is successful as well.
public IEnumerable<tbl_Category> GetALL()
{
return db.tbl_Category.ToList();
}
public tbl_Category GetByID(int Id)
{
return db.tbl_Category.Find(Id);
}
public void Insert(tbl_Category cat)
{
db.tbl_Category.Add(cat);
}
public void Delete(int Id)
{
tbl_Category cat = db.tbl_Category.Find(Id);
db.tbl_Category.Remove(cat);
}
Upvotes: 0
Views: 30
Reputation: 6417
I think you have to call the SubmitChanges() / SaveChanges() on the data context.
Upvotes: 2