SQLiteConstraintViolationException when working with a model that was saved in a previous version

Product(s): WaterGEMS, WaterCAD, HAMMER, SewerGEMS, SewerCAD, StormCAD, CivilStorm
Version(s): 10.00.00.XX, 10.XX.XX.XX
Area: Other


The below error may occur in the initial CONNECT Edition release ( of WaterGEMS, WaterCAD or HAMMER, when working on a model that was originally created in an older version.

In SewerGEMS, CivilStorm, StormCAD and SewerCAD, a very similar error may occur when performing a task (in a model originally created in an older version) that requires the conduit descriptions to be updated (and you may see a dialog stating "Updating Conduit descriptions") or when manipulating certain conduits.

Haestad.SQLite.SQLiteConstraintViolationException: 19: columns DomainElementID, AlternativeID are not unique

   at Haestad.SQLite.SQLiteLibrary.ThrowException(Int32 errorCode, String errorMessage)
   at Haestad.SQLite.SQLiteCommand.ExecuteNonQuery()
   at Haestad.Domain.DataObjects.Sqlite.SqliteAlternativeRecordDataBrokerBase.MakeRecordLocalBasic(String tableName, StringFilterDelegate fieldsToCopyFilterDelegate, Int32 fromDomainElementID, Int32 fromAlternativeID, Int32 toDomainElementID, Int32 toAlternativeID)



To resolve this issue, for WaterGEMS, WaterCAD or HAMMER, please upgrade to CONNECT Edition build (or greater, when available). If you are not able to upgrade from build 49 to build 50, please contact Technical Support for the latest Cumulative Patch set for version

For SewerGEMS, CivilStorm, StormCAD and SewerCAD, in some cases this issue was fixed by exporting the entire model (selecting all elements) to a submodel (File > Export > Submodels) and then re-importing the submodel (File > Import > Submodels) into a fresh model. See the steps to follow in this case;

1. Select all elements in the model (Home > Drawing > Select > Select All) or manually select all elements.

2. Go to File > Export > Submodels

3. Save the .sqlite file in a separate location. Close the model.

4. Go to File > Import > Database. Browse to the location of the newly saved database file (.sqlite) and open it.

In this process it should be ensured that the unit system (SI or US customary) is maintained before exporting to a submodel and after importing it. There could be some changes in both the models and there would be likely loss of the color coding or annotations setup of the previous model, however, the hydraulic data for the elements would be maintained. It is suggested to compare the original and the new models to identify if there are any missing elements.

If the above solution doesn't work contact technical support and share the model files (.wtg, .wtg.sqlite / .stsw, .stsw.sqlite) alongwith the application log file too. A simple way for this is to go to File > Save to Package and choose the option to "Include application log file" to include it automatically. See this article for details on files required: What files are needed to open a model in an OpenFlows product?

Defect #616558

See Also

Compacting a database for optimal performance and general troubleshooting