Archive for August, 2008

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints

Wednesday, August 27th, 2008

Visual Studio 2008 keeps me entertained all day long:)

I have a really complicated project, with several tables and views and stored procedures hooked upon it. I’m using XSD as an intermediate abstraction layer.

The error message “Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints” kept haunting me for days; I double checked anything:

  • there were no duplicate keys whatsoever
  • there were no NULL values, I experienced with IsNull(..) for fields
  • even empty tables had this error.

Finally, I figured out, that and any changes to the database schema, even the change of the length of any column triggers the above error, the XSD Schema simply does not recieve the changes; even when I click Refresh Schema.

The one and only working solution is to open the given XSD file, and simply delete and re-add the errorous object.