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 6239349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:22:43+00:00 2026-05-24T11:22:43+00:00

I am accessing my database through ADO.NET Entity framework in MVC 3 Application. I

  • 0

I am accessing my database through ADO.NET Entity framework in MVC 3 Application.

I am updating my database through Stored Procedure.

But the changes are not reflected at run time.I mean to say i am able to see the changes only after restarting it.

What is the reason for the problem and How can i avoid it ?
I am using Repository pattern So at repository My code look like this

Ther Is One Function Which Save Changes

public void SaveNewAnswer(AnswerViewModel answer,string user)
{

        SurveyAdminDBEntities _entities = new SurveyAdminDBEntities();
        _entities.usp_SaveNewAnswer(answer.QuestionId, answer.AnswerName, answer.AnswerText, answer.AnswerOrder, answer.Status, user);
        _entities.SaveChanges();

}

Data Retreival Code

public IEnumerableGetMultipleChoiceQuestions(string questionId)
{

        SurveyAdminDBEntities _entities = new SurveyAdminDBEntities();
        _entities.AcceptAllChanges();
        _entities.SaveChanges();
        return _entities.usp_GetMultipleChoiceQuestions(Int32.Parse(questionId));
    }

But Changes are not reflected till the time i don’t clode the session of the browser and run it again .

Please help !

Thank You In advance

  • 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-24T11:22:44+00:00Added an answer on May 24, 2026 at 11:22 am

    Are you calling context.SaveChanges() on your Entities (DbContext/ObjectContext) object? Are you using a transaction that you haven’t committed?

    If you have an uncommitted transaction in your sproc, you can try creating your own entity transaction and seeing if committing your transaction will commit the nested transaction as well. The problem is that calling SaveChanges() automatically begins and commits a transaction, so this may not be any different than that.

    I would also call _entities.AcceptAllChanges() in your save operation.

    public void SaveNewAnswer(AnswerViewModel answer,string user) 
    {
        SurveyAdminDBEntities _entities = new SurveyAdminDBEntities();
        _entities.Connection.Open();
        System.Data.Common.DbTransaction tran = _entities.Connection.BeginTransaction();        
    
        try
        {
            _entities.usp_SaveNewAnswer(answer.QuestionId, answer.AnswerName, answer.AnswerText, answer.AnswerOrder, answer.Status, user);
            _entities.SaveChanges(); // automatically uses the open transaction instead of a new one
            tran.Commit();
        }
        catch
        {
            tran.Rollback();
        }
        finally
        {
            if (_entities.Connection.State == System.Data.ConnectionState.Open)
                    _entities.Connection.Close();
    
            _entities.AcceptAllChanges();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have business restriction in accessing the database only through stored procedure calls. Caching
Using asp.net MVC in c#, I am making a call to a stored procedure
I am writing an application where I will be accessing the database from django
I use ASP.Net with NHibernate accessing a Pgsql database. For some of our Objects,
I have faced a very strange situation here. I am accessing database (MDB) through
What are the security implications of websites accessing database views instead of using stored
I'm just getting started with ASP.NET MVC and am going through the NerdDinner tutorial.
I have wrote a few simple Rails application, accessing the database via the ActiveRecord
I'm trying to decide on the best strategy for accessing the database. I understand
I'm using System.Data.Linq.DataContext file for accessing a mdf Database I want to use 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.