0

I am performing a create operation on an entity. The entity is a Function import of a stored procedure. No exceptions are thrown, but I am getting nothing new in the database. I checked my connection string a couple times, pointing to Dev environment like it should. I stuck on breakpoint on the ObjectResult<T> and it hit and flows through to return View(). What else can I do to debug/troubleshoot this?

[HttpPost]
        public ActionResult Create(Tracker_CreateUser_Result model)
        {
            string currentUser = Environment.UserDomainName + "\\" + Environment.UserName;
            TrackerEntities context = new TrackerEntities();

            model.User_Created_Date = DateTime.Now;
            model.User_Created_Logon_Name = currentUser;
            model.User_Updated_Logon_Name = currentUser;
            model.User_Updated_Datetime = DateTime.Now;
            System.Data.Objects.ObjectResult<Tracker_CreateUser_Result> result = context.Tracker_CreateUser(model.User_Name,model.User_Logon_Name,model.User_Token,model.User_Demo,model.User_Demo_Logon_Name,model.User_Interface,model.User_Status,model.User_Reason_for_Edit,model.User_Created_Logon_Name,model.User_Created_Date,model.User_Updated_Logon_Name,model.User_Updated_Datetime);
            context.SaveChanges();//UPDATE
            ViewBag.Message = "Successfully created user";
            return View();
        }

1 Answer 1

1

You should call context.SaveChanges() after adding the entity.

Hope this helps :)

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

2 Comments

Thanks, I was quite hopeful that would work. Same problem, no errors - no updates in DB. Placement located in OP.
Context.SaveChanges() was not necessary. I had cheated a little bit in creating my Entity. I originally performected SELECT * in the stored proc just to make it easy to generate the Complex Type. Turns out this needs to be undone once you have the complex type. You can copy the complex type to a new one and update the original. Maybe not a good idea in general, easier to type out all the variables...lengths..etc :\

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.