Error: "The DELETE statement conflicted with the REFERENCE constraint" after truncating EventLog table

Overview

If you are seeing the following error in your site logs, there may be an issue with the SQL server tables that store your EventLog:

The DELETE statement conflicted with the REFERENCE constraint "FK_ExceptionEvents_EventLog". 
The conflict occurred in database "databaseName", table "dbo.ExceptionEvents",
column 'LogEventID'.

The DNN event log stores records of exceptions and other registered events. This error can be caused by a failed EventLog clearing, or simply by errors or corruption in the table.

 

Environment

To perform this fix, you'll need:

  • Platform/Evoq 7.4 and above
  • Access to the SQL Server

 

Solution

  1. Examine the error message to get the foreign key location. For example:
    The DELETE statement conflicted with the REFERENCE 
    constraint "FK_ExceptionEvents_LogEventId". <-- Foreign Key name
    The conflict occurred in database "EvoqContent" <-- Database Name
    , table "dbo.ExceptionEvents" <-- Table Name
    , column 'LogEventID'. <-- Column Name
  2. Open SSMS and expand the Tables view for your database.
    SSMSDatabases.png

  3. Find the table and expand the keys sub-menu. You should find the foreign key listed in the error message:
    FKList.png
  4. Right-click on the key, then select Modify
  5. On the next window, expand the INSERT and UPDATE specification, then set the Delete Rule to Cascade:
    FKSettings.png
  6. Select Close, then save the table through File > Save (or Ctrl+S). You will get a warning about saving the table to the database.

 

Testing

The error should stop appearing in your site logs. Since this error is tied to Scheduler job frequency, you may need to wait until the next cleanup job runs.

Comments

1 comment

  • Avatar
    Parghi Prakash

    Thank you

    1
    Comment actions Permalink

Please sign in to leave a comment.