0

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);
        }

1 Answer 1

2

I think you have to call the SubmitChanges() / SaveChanges() on the data context.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.