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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:12:19+00:00 2026-06-17T14:12:19+00:00

Im saving some locations/cities in my database. My locations/cities DOES get saved althrough my

  • 0

Im saving some locations/cities in my database.

My locations/cities DOES get saved althrough my this._entities.SaveChanges(); throws an execption that goes something like:

The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message:AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager. Make sure that the key values are unique before calling AcceptChanges.

I dont really know whats the problem since it worked before and this changes should not affect it really…

Here’s some code:
First off i get all the objects into currentLocation.
I loop them through a foreach to add item to method Add().
Last i call for _entites.SaveChanges(). Everything gets saved but i get an error…

           var webService = new WeatherWebService();
            currentLocation = webService.FindLocation(city);

            // ...save the user in the database.
            foreach (var item in currentLocation)
            {
                this._repository.Add(item);
            }

            this._repository.Save();

    public override void Add(Location location)
    {
        this._entities.Locations.AddObject(location);
    }

    public override void Save()
    {
        this._entities.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-06-17T14:12:20+00:00Added an answer on June 17, 2026 at 2:12 pm

    Problem sloved, seems you have to output a id from the Auto Increment… else it will make each post id 0 and therefor it thinks its several with same ID.

    Used something like NewId as @@SCOPE_IDENTIY

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

Sidebar

Related Questions

I am saving some pictures on the SD card in this way: File dir
I have a action class for saving some data to a database.In action class
I have a DataSet with some Datatables and I am saving this DataSet as
I am trying to make saving and loading easier for some GUIs that I've
I have some javascript code that saves a cookie. However, if after saving the
I am trying to get some locations in New York using FourSquare API using
My Java application is saving stuff in 'user.home' but on windows this does not
I have some code that does not seem to operate the way it should.
i want to build an app for windows mobile that can get GPS locations(longitude
My app is saving some images on the SD Card, in the AppImages directory

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.