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

  • Home
  • SEARCH
  • 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 913877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:37:43+00:00 2026-05-15T17:37:43+00:00

I use ADO.net Entity Data model for work with database. In my program, I

  • 0

I use ADO.net Entity Data model for work with database.

In my program, I want to update a record of user table, so I use the code below to do this.

In this function I send changed user info and then overwrite the information with the current user information.

After I run objUser = _user; and then call objContext.SaveChanges(); to save the changes.

But when I do this, the changes are not persisted to the database. I use this code for another programs but in this case the code does not work!

public void Update(tbLiUser _user)
{
    LinkContext objContext = this.Context;

    tbLiUser objUser = objContext.tbLiUsers.First(u => u.tluId == _user.tluId);
    objContext.Attach(objUser);
    objUser = _user;

    objContext.SaveChanges();
}
  • 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-15T17:37:44+00:00Added an answer on May 15, 2026 at 5:37 pm

    First of all, if you already retrieve objUser from the objContext, there’s really no point in attach that user to the context just after retrieving it. So I would drop this line here entirely:

    objContext.Attach(objUser);
    

    Also – you might just need to update the objUser on a per-property basis from the values in _user instead of just assigning the whole object.

    To help you avoid lots of tedious code, you could use something like AutoMapper to let you assign properties from one object type to the other. Or you could create a smart routine that would compare the two objUser and _user and update only those properties on objUser that are in fact different from the values in _user – shouldn’t be too hard to create that method:

    objUser.UpdateValuesFromOtherUser(_user);
    objContext.SaveChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a northwind database and I use ADO.NET Entity Data Model
Are you supposed to use one ADO.NET Entity Data Model for each table? Or
I got a ADO.NET Entity Data Model that I want to use on several
I am using ASP.Net MVC with ADO.Net Entity Data Model. When I use ToList()
I am using ASP.Net with ADO.Net Entity Data Model. I use this for add
I have an ADO .Net Entity Data Model for my database. In this Model
I am trying to use the ADO.NET Entity Data Model in a way that
I use ADO.NET Entity Data Model in ASP.NET with MySql. I tried many collocation
I want to add ADO.NET Entity Data Model to my project. I am using
I use ADO.NET Entity-Framework, I have a page that is data-bound to an entity

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.