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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:06:22+00:00 2026-06-05T04:06:22+00:00

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities

  • 0

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

I get this error, but I am the only person using the database. I am using Entity Framework 4.1 with DBContext.

I am updating my records and SQL Profiler is showing a queue being sent in. What could be the causes of this issue?

The post:

  [HttpPost]
  public ActionResult EditUser(User user)
  {                 
       uow.UserRepository.Update(user);
       uow.Save();
       return RedirectToAction("Index", "User");

  }

On this call:

  public void Save()
  {
        _context.SaveChanges();
  }

This is how it is attached

  public virtual void Update(TEntity entityToUpdate)
  {
         dbSet.Attach(entityToUpdate);
        context.Entry(entityToUpdate).State = EntityState.Modified;
  }

Update:

public class UnitOfWork : IDisposable
{
    private StudentSchedulingEntities _context = new StudentSchedulingEntities();
    private GenericRepository<User> userRepository;
    private GenericRepository<UserRole> userRoleRepository;
    private bool disposed = false;

    public GenericRepository<User> UserRepository
    {
        get
        {

            if (this.userRepository == null)
            {
                this.userRepository = new GenericRepository<User>(_context);
            }
            return userRepository;
        }
    }
    public GenericRepository<UserRole> UserRoleRepository
    {
        get
        {

            if (this.userRoleRepository == null)
            {
                this.userRoleRepository = new GenericRepository<UserRole>(_context);
            }
            return userRoleRepository;
        }
    }

    public void Save()
    {
        _context.SaveChanges();
    }
    protected virtual void Dispose(bool disposing)
    {
        if (!this.disposed)
        {
            if (disposing)
            {
                _context.Dispose();
            }
        }
        this.disposed = true;
    }
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }
}
  • 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-06-05T04:06:23+00:00Added an answer on June 5, 2026 at 4:06 am

    The ID field must be there in order to update the information properly. Otherwise, it will be throw a null. (I forgot to put the hidden field for ID in)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure which is called inside a trigger on Insert/Update/Delete. The
Can I find out when the last INSERT, UPDATE or DELETE statement was performed
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
I have problem when I tried to update two tables in one Store Procedure
I have an app on the Store for which we’re readying an update. The
I have a list of users in local store that I need to update
I have mysql error with code 1451. Cannot delete or update a parent row:
I am well aware of SQL statements such as select, insert, update and delete.
I found a solution for people who get an exception: Store update, insert, or
For INSERT , UPDATE and DELETE SQL statements executed directly against the database, most

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.