Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1079427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:52:04+00:00 2026-05-16T21:52:04+00:00

I am using MVC 2 and EF 4. I am trying to update my

  • 0

I am using MVC 2 and EF 4.

I am trying to update my Application entity using my own stored procedure, but it is not updating. I checked out SQL Profiler and it is not even reaching the database. I also use an insert stored procedure and it works fine. Both stored procedures (insert and update) are mapped correctly. Does anyone know what I am doing wrong?

Here is my EditApplication action event:

[HttpPost]
public ActionResult EditApplication(int id, ApplicationViewModel applicationViewModel)
{
   if (ModelState.IsValid)
   {
      try
      {
         Mapper.CreateMap<ApplicationViewModel, Application>();
         var application = (Application)Mapper.Map(applicationViewModel, typeof(ApplicationViewModel), typeof(Application));
         application.ApplicationID = id;

         UpdateModel(application);

         // Edit application
         applicationRepository.UpdateApplication(application);

         // If success, redirect to confirmation page
         return RedirectToAction("Confirmation", new { id = application.ApplicationID });
      }
      catch (Exception ex)
      {
         // TODO
      }
   }

   applicationViewModel.AccountTypes = accountTypeRepository.GetAccountTypes();
   return View("CreateApplication", applicationViewModel);
}

Here is my repository Update method:

private MyEntities db = new MyEntities();

public void UpdateApplication(Application application)
{
   db.SaveChanges();
}

Thanks
Brendan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:52:05+00:00Added an answer on May 16, 2026 at 9:52 pm

    This my changes, not sure if it is correct but it is working.

    Action event:

    [HttpPost]
    public ActionResult EditApplication(int id, ApplicationViewModel applicationViewModel)
    {
       var application = applicationRepository.GetApplicationByID(id);
    
       if (ModelState.IsValid)
       {
          try
          {
             Mapper.CreateMap<ApplicationViewModel, Application>();
             application = (Application)Mapper.Map(applicationViewModel, typeof(ApplicationViewModel), typeof(Application));
    
             application.ApplicationStateID = 1;
             application.ApplicationID = id;
    
             // Edit application
             applicationRepository.UpdateApplication(application);
    
             // If success, redirect to confirmation page
             return RedirectToAction("Confirmation", new { id = application.ApplicationID });
          }
          catch (Exception ex)
          {
             // TODO
          }
       }
    
       applicationViewModel.AccountTypes = accountTypeRepository.GetAccountTypes();
       return View("CreateApplication", applicationViewModel);
    }
    

    The update method in my repository:

    private MyEntities context = new MyEntities();
    
    public void UpdateApplication(Application application)
    {
       context.Applications.ApplyCurrentValues(application);
       context.SaveChanges();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP.NET MVC when trying to get the information stored on my Session[objectName] from
MVC 2 I'm trying to post to an MVC action using jQuery, but I'm
I'm trying to write some code using pure SQL using ASP.NET MVC. I assume
When using ASP.NET MVC plus Entity Framework, and trying to implement a generic repository
I am trying to send email using gmail from my mvc application. I am
I am using subsonic to access my DB in a mvc application. When trying
I am trying to update an entity using Entity Framework 4.1 in my asp.net
Trying to execute a Powershell cmdlet from a MVC 3 Controller using impersonation but
I need help with trying to insert a record using MVC and Entity Framework.
I am trying to develop my first PhoneGap application, using MVC.NET to serve the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.