3

I have an issue where attempting to delete a row from a table generates this error.

Error Code: 80004005

Message: The key cannot be deleted. The key to be deleted is already deleted from an index by another concurrent session.

Minor Err.: 25161

Source: SQL Server Compact ADO.NET Data Provider

This may be related to a duplicate primary key entry in the database, yes I said duplicate primary key. This is a known issue with certain builds of Sql Compact. Does anyone know how I might be able to delete this row? There is no other session with the database nor is there a 'cascade on delete' for the index.

File Version: 4.0.8876.1

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
fanuc_bob
  • 857
  • 1
  • 7
  • 20
  • What build (file version) of SQLCE are you using? – ErikEJ Jul 21 '15 at 14:15
  • 1
    I encountered the same issue. The problem was definitely not caused by a lack of uniqueness. We use 64-bit version 4.0.8902.1 and entity framework version 6.1.3. – iljon Sep 27 '16 at 11:11

1 Answers1

1

After EF6 migration i have same issue. I used this tool for repair database: https://github.com/ErikEJ/SqlCeCmd/releases like that

SqlCeCmd40.exe -d "Data Source=C:\base.sdf" -e repairrecover

In my case it solve issue

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
dev
  • 11
  • 1