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

I'm trying build my application using REST and Spring MVC. For some entities I
I'm trying to delete a database record using ASP.NET MVC, Fluent, and NHibernate. See
I'm trying out the Razor ViewEngine from ASP.NET MVC 3 Preview 1 and I'm
I'm about to begin building a website using the ASP.NET MVC framework and I'm
I am using T4MVC to redirect to another action return RedirectToAction(MVC.MyController.MyAction());. In result it
I'm trying to buid a site with the following: VS 2010 (for the updated
Hi I'm building my first MVC 2 app and I'm really confused by all
I'm trying to add a search box to a master page in an ASP.Net
I'm using the Tornado framework (Python) on GAE. I'm still kind of new to

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.