Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a problem with my application SharePoint. The problem is that I added a List in my SharePoint site (directly in SharePoint), then I used SPMetal LINQ to generate a File in which I can recover my lists. Until now every thing is alright. But now I need to delete my list and create it again from a Content type and a list definition (using Visual Studio 2010). I created another file.cs with the SPMetal command but when I try to recover the list I get the error "An item (element) with the same key has already been added" (this is a translation of the error message, the original in french is: Un élément avec la même clé a déjà été ajouté.). I tried to create another Content type with a different name and different fields and it works good, but the problem is that my list should have the same name as the first one I created in SharePoint and the same fields. I don't know what to do, what's the element that was been added with the same key!!!?? I even deleted my site collection and created another one but I still have the same problem. Here is the code that generates the problem, in my code behind of my user control:

CandidatsDataContext dc = new CandidatsDataContext(SPContext.Current.Web.Url);
 EntityList<CandidatsCT_Candidats> list = dc.Candidats; 

which calls this function in file.cs generated by SPMetal linq:

[Microsoft.SharePoint.Linq.ListAttribute(Name="Candidats")]
    public Microsoft.SharePoint.Linq.EntityList<CandidatsCT_Candidats> Candidats {
        get {
            return this.GetList<CandidatsCT_Candidats>("Candidats");
        }
    }

Then I get this error msg: "An item with the same key has already been added" Please help me, I spend more than a week trying to resolve this problem.

share|improve this question
    
    
Please use some tool to fetch the corresponding log entry from the ULS logs. If this error happens when trying to add a list, then either a list or content type with the same GUID might be in the site/site collection. Check the recycle bin for the site and site collection. –  Renan Oct 16 '13 at 18:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.