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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:33:31+00:00 2026-05-25T03:33:31+00:00

Im getting angry with this error and cannot solve it. Please, some Jedi master

  • 0

Im getting angry with this error and cannot solve it.
Please, some Jedi master help me.

I’m trying to save trhee Entities: Region, Content and RegionalContent. Region is OK but Regional Content has to be associated with one Content and each Content may have Many RegionalContents(Translations). But I always get a DbUpdateException that has a UpdateException that has a SqlCeException that says something like:

*Impossible to insert a duplicated value with same index. Table name = XBLContents,Constraint name = PK_XBLContents_000000000000001C *

I’m debugging it for some days and could not find the error. Please, note that I’m still a little Padawan.

This is the code that saves the objects in they proper Tables:

Region region;
if (!db.Regions.Any(x => x.ID == Locale))
{
    region = new Region { ID = Locale };
    db.Regions.Add(region);
    db.SaveChanges();
}
else
    region = db.Regions.SingleOrDefault(x => x.ID == Locale);

for (int i = start; i < (start + 2); i++)
{
    string guid = itens[i].Groups["guid"].Value;

    Content c = new Content(guid);
    if (!db.Contents.Any(x => x.GUID == guid))
    {
        c.Type = Type.ToString();
        c.PopularInfo(Locale);

        db.Contents.Add(c);
    }
    else
        c = db.Contents.SingleOrDefault(x => x.GUID == c.GUID);

    RegionalContent regionalcontent;                
    if (!db.RegionalInfos.Any(x => x.ContentId == guid && x.RegionId == Locale))
    {


        if (c.HTML == null)
            c.PopularInfo(Locale);

        regionalcontent = new RegionalContent(c, Locale);
        regionalcontent.Region = region;
        regionalcontent.Name = HttpUtility.HtmlDecode(itens[i].Groups["name"].Value);

        db.RegionalInfos.Add(regionalcontent);

        db.Contents.Add(c);
        db.SaveChanges();
    }
    else
        regionalcontent = db.RegionalInfos.SingleOrDefault(x => x.ContentId == guid && x.RegionId == Locale);

    c.RegionalInfo.Clear();
    regionalcontent.Region = region;
    c.RegionalInfo.Add(regionalcontent);

    Contents.Add(c);
}
  • 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-25T03:33:31+00:00Added an answer on May 25, 2026 at 3:33 am
    1. You are calling SingleOrDefault when you know 1 already exists. Just use Single.
    2. I would not call SaveChanges to the very end.
    3. Are you sure the GUIDs are unique every time?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this error while trying to erase the last element of a list. I
Getting this error while I am trying to run /compile/build a Proiject Incompatible Types
getting this error while linking an app, some one an idea? ld: duplicate symbol
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/
Getting a 'marshal data too short' error when trying to install the mysql gem
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Getting the following error: "Warning: Cannot modify header information - headers already sent by
Getting this error: Each GROUP BY expression must contain at least one column that

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.