U4-2270 - ImportDocumentType - A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]

Created by Lee Kelleher 24 May 2013, 15:17:52 Updated by Morten Christensen 27 May 2013, 10:48:21

Using Umbraco 6.0.5, SqlCe (with Standard Website MVC starter kit installed). When trying out the uSync package to import DocTypes, the following YSoD occurred:

Server Error in '/' Application.

A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlServerCe.SqlCeException: A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]] System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr) +269 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor) +670 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) +474 System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() +44 Umbraco.Core.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Persistence\PetaPoco.cs:1361 Umbraco.Core.Persistence.Database.Insert(Object poco) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Persistence\PetaPoco.cs:1367 Umbraco.Core.Persistence.Repositories.ContentTypeRepository.PersistUpdatedItem(IContentType entity) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Persistence\Repositories\ContentTypeRepository.cs:254 Umbraco.Core.Persistence.Repositories.RepositoryBase2.PersistUpdatedItem(IEntity entity) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Persistence\Repositories\RepositoryBase.cs:207 Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Persistence\UnitOfWork\PetaPocoUnitOfWork.cs:107 Umbraco.Core.Services.ContentTypeService.Save(IEnumerable1 contentTypes, Int32 userId) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Services\ContentTypeService.cs:166 Umbraco.Core.Services.PackagingService.ImportContentTypes(XElement element, Boolean importStructure, Int32 userId) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\Services\PackagingService.cs:242 jumps.umbraco.usync.SyncDocType.ReadFromDisk(String path, Boolean structure) +337 jumps.umbraco.usync.SyncDocType.ReadFromDisk(String path, Boolean structure) +400 jumps.umbraco.usync.SyncDocType.ReadFromDisk(String path, Boolean structure) +400 jumps.umbraco.usync.SyncDocType.ReadFromDisk(String path, Boolean structure) +400 jumps.umbraco.usync.SyncDocType.ReadAllFromDisk() +127 jumps.umbraco.usync.uSync.ReadAllFromDisk() +228 jumps.umbraco.usync.uSync.RunSync() +239 jumps.umbraco.usync.uSync.DoOnStart() +138 Umbraco.Core.EnumerableExtensions.ForEach(IEnumerable1 items, Action1 action) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\EnumerableExtensions.cs:89 Umbraco.Core.CoreBootManager.Complete(Action1 afterComplete) in c:\Program Files (x86)\teamcity\buildAgent\work\e145e9ed82478b40\src\Umbraco.Core\CoreBootManager.cs:156 Umbraco.Web.WebBootManager.Complete(Action1 afterComplete) +31

[HttpException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12863325 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = cmsDocumentType,Constraint name = PK_cmsDocumentType ]] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12721257

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033

Further details on the forum: http://our.umbraco.org/projects/developer-tools/usync/usync/41260-v605-SqlCe-A-duplicate-value-cannot-be-inserted-into-a-unique-index

Comments

Morten Christensen 27 May 2013, 10:48:21

Was simply a case of making sure the list of allowed templates didn't contain duplicates, so was an easy fix. Thanks for reporting.


Priority: Normal

Type: Bug

State: Fixed

Assignee: Morten Christensen

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.0.5

Due in version: 6.0.6

Sprint:

Story Points:

Cycle: