"Unexpected Errors during the file conversion" or "foreign key constraint failed"

Product(s): WaterCAD, WaterGEMS, HAMMER, FlowMaster, SewerGEMS, CivilStorm, StormCAD, SewerCAD
Version(s): 10.XX.XX.XX,
Area: Layout and Data Input


When attempting to open a model saved in an older version, one of the following errors occur:

”There were unexpected errors during the file-conversion process to .sqlite, probably due to integrity problems in the .mdb file. Please contact Technical Support to resolve these errors.”


"19: foreign key constraint failed"

Solution - WaterGEMS / WaterCAD / HAMMER

This may indicate that the model is corrupt, or that the file is not actually a WaterGEMS, WaterCAD or HAMMER model.

First, if you have WaterGEMS or WaterCAD version, this may be related to a known issue that has been resolved in later versions starting with Please download a later version to resolve the issue.

If the file is a .MDB file, make sure it is not an Access Database file (unrelated to WaterGEMS/WaterCAD/HAMMER) and make sure it is not the intermediate Geodatabase file used with WaterGEMS for ArcMap integration (which is separate from the actual model database). If the file has an extension of .MDB and you have Microsoft Access, you can open the file in Access and examine the tables. If there are only tables corresponding to the element types like "junction", and no tables beginning with "HMI...", then the file is an ArcMap intermediate geodatabase.

If you are opening an old model that was converted and includes the presentation settings .XML file, try renaming or deleting the XML file to see if that helps. If it does, you will need to recreate the color coding and annotations as the .XML file stores that information.

If you are seeing the "foreign key constraint failed" error and you have determined that the file is indeed a model file, try the following:

1) Open the program, but don't open any model yet.

2) Go to File > Database Utilities > Compact Database

3) Select the .SQLITE file associated with the model in question, then choose the option to "Purge to save space"

4) Click OK, allow the operation to complete, then try reopening the model.

If the above does not help, please contact technical support to investigate likely database corruption: Forum | Service Request. Reference # 771218.

Solution - FlowMaster

This issue has been known to occur when upgrading a FlowMaster V8i or earlier model (which stores project data in a MDB file) to the CONNECT Edition (which stores project data in a SQLITE file). When FlowMaster CONNECT Edition tries to upgrade the database from Access MDB to SQLITE, if there are problems or corruption in the database, it can surface and present the error in question. The model may open without error in V8i.

To resolve this issue, try opening  the .FM8.MDB file in Microsoft Access. If you encounter an error right away, it is a good indication that there is corruption in the database. If asked to repair, confirm and proceed, dismissing any errors that appear. Then, try re-opening in FlowMaster CONNECT Edition. Once open, when you re-save, it will save in the new SQLITE format.

If this does not help or you do not have Microsoft Access, send the data files to Technical Support (for example post on our Forum).

In the case of FlowMaster, the "Unexpected Errors during the file conversion" error may also include a crash with the following details:

System.ApplicationException: Error in the application.

at Haestad.Framework.Application.DomainDatabaseFile.HandleMissingProjectFile(ProjectProperties app)
at Haestad.Framework.Application.ProjectFileBase.Open(ProjectProperties app)
at Haestad.Framework.Application.ProjectBase.Open(ProjectProperties app)

Solution - SewerGEMS / CivilStorm / StormCAD / SewerCAD

In a storm-sewer product such as SewerGEMS, when rebuilding / updating a model with ModelBuilder the crash is known to occur. It is typically seen in cases where model elements (with associated GIS-ID's) are deleted in a model and then are tried to rebuild using ModelBuilder.

The work-around to this is to delete the associated GIS-ID's of the deleted elements first and then rebuild the model via ModelBuilder. The crash would not occur then.

See Also

Error message 41303 "Cannot open report file" 

Error opening model : Not a Valid Haestad Methods File