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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:06:40+00:00 2026-05-25T19:06:40+00:00

The changes to the database were committed successfully, but an error occurred while updating

  • 0

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.

Is the error message i get. here are the two functions i use…

    public IList<string> GenerateVersions(decimal id, decimal fId, string folderName, string filename, string objFile)
    {
        List<string> generatedFiles = new List<string>();

        foreach (var tCmdSets in db.IMG_SETTINGS_CMDSETS.Where("it.SETTINGS_FOLDER_ID = @folderid", new ObjectParameter("folderid", id)))
        {
            var strDestinationPath = ImageResizer.Util.PathUtils.RemoveExtension(Path.Combine(tmpDefaultFolder, tCmdSets.SETTINGS_CMDSET_DESTINATION, filename));
            ResizeSettings objResizeCommand = new ResizeSettings(tCmdSets.SETTINGS_CMDSET_COMMAND);

            var strCreatedFile = ImageBuilder.Current.Build(objFile, strDestinationPath, objResizeCommand, false, true);
            generatedFiles.Add("### File created: (" + folderName + " » " + tCmdSets.SETTINGS_CMDSET_NAME + " ») " + Path.GetFileName(strCreatedFile));

            IMG_UPLOAD_GENERATED_FILES tObjGenerated = new IMG_UPLOAD_GENERATED_FILES();

            tObjGenerated.UPLOAD_GENERATED_FILE_NAME = Path.GetFileName(strCreatedFile);
            tObjGenerated.UPLOAD_GENERATED_PATH = Path.GetDirectoryName(strCreatedFile);
            tObjGenerated.SETTINGS_CMDSET_ID = tCmdSets.SETTINGS_CMDSET_ID;
            tObjGenerated.UPLOAD_FILE_ID = fId;

            dbHandler.IMG_UPLOAD_GENERATED_FILES.AddObject(tObjGenerated);
            dbHandler.SaveChanges();
        }
        return generatedFiles;
    }

    public ActionResult UploadBulkFiles(decimal id)
    {
        IMG_SETTINGS_FOLDERS img_settings_folders = db.IMG_SETTINGS_FOLDERS.Single(i => i.SETTINGS_FOLDER_ID == id);
        string strBulkDirectory = Path.Combine(tmpDefaultFolder, img_settings_folders.SETTINGS_FOLDER_BULK);
        string[] objFiles = Directory.GetFiles(strBulkDirectory);
        List<string> lstOuput = new List<string>();

        foreach (var tFile in objFiles)
        {
            System.IO.File.Move(tFile, Path.Combine(tmpDefaultFolder, "masters", img_settings_folders.SETTINGS_FOLDER_NAME, Path.GetFileName(tFile)));

            lstOuput.Add("### File moved to masters (" + img_settings_folders.SETTINGS_FOLDER_NAME + " ») " + Path.GetFileName(tFile));

            IMG_UPLOAD_FILES tObjUploadedFile = new IMG_UPLOAD_FILES();

            tObjUploadedFile.UPLOAD_FILE_NAME = Path.GetFileName(tFile);
            tObjUploadedFile.SETTINGS_FOLDER_ID = img_settings_folders.SETTINGS_FOLDER_ID;

            dbHandler.IMG_UPLOAD_FILES.AddObject(tObjUploadedFile);
            dbHandler.SaveChanges();

            var objGeneratedFiles = GenerateVersions(img_settings_folders.SETTINGS_FOLDER_ID,tObjUploadedFile.UPLOAD_FILE_ID, img_settings_folders.SETTINGS_FOLDER_NAME, Path.GetFileName(tFile), Path.Combine(tmpDefaultFolder, "masters", img_settings_folders.SETTINGS_FOLDER_NAME, Path.GetFileName(tFile)));
            lstOuput.AddRange(objGeneratedFiles);
        }
        if (lstOuput.Count > 0)
        {
            return PartialView("UploadSingleFile", lstOuput);
        }
        else
        {
            return PartialView("NoUploads");
        }
    }

DATA MODEL

IMG_UPLOAD_FILE

  • UPLOAD_FILE_ID (PK)
  • UPLOAD_FILE_NAME
  • SETTINGS_FOLDER_ID

IMG_UPLOAD_GENERATED_FILES

  • UPLOAD_GENERATED_FILE_ID (PK)
  • UPLOAD_GENERATED_FILE_NAME
  • UPLOAD_GENERATED_FILE_PATH
  • SETTINGS_CMDSET_ID
  • UPLOAD_FILE_ID
  • 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-25T19:06:40+00:00Added an answer on May 25, 2026 at 7:06 pm

    The closest I can come to finding an answer is:

    Because Oracle uses a Sequence + Trigger to make “Auto Ident” values, it seems like when the entity framework adds an object at saves it, the value return is still 0, because the trigger/sequence haven’t updated it yet.

    Because of the 0 number, the ObjectMannager will think that multiple objects with the entity key of 0 are in conflict.

    I don’t have a “bullet proof” solutions, but have rewritten my solutions to handle it another way.

    \T

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

Sidebar

Related Questions

first of all here is the message The changes to the database were committed
As you develop an application database changes inevitably pop up. The trick I find
What is the easiest way to apply to database changes to the structure (not
How can one use Triggers for Logging History of database changes in MySQL? If
I'm writing a tool which will push changes to database after commit to svn.
How can I monitor an SQL Server database for changes to a table without
What is the best way to track changes in a database table? Imagine you
I've got a problem in my database - somehow changes sometimes are not being
I have been tasked with developing a solution that tracks changes to a database.
For those agile practitioners out there... How do you manage changes to a database

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.