Search code examples
asp.netstrongly-typed-dataset

How to change foreign Key restraint on Dataset with Table Adapter


I have a Dataset that has 3 TablesAdapters linked together (both the relationships and foreign-keys came over from the DB design). I'm trying now to to bind the TableAdapter with the foreign keys on it, I get the following:

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

so after a little digging, I found that it doesn't like that I have Identical foreign keys on the TableAdapter (even though the DB contraints are OK with this).

How to I get my DataSet (or the TableAdpapter) to only look at the primary key of the table as a contraint?


Solution

  • Ok, so 5 seconds after I post this I find the answer (isn't that how it always works?)

    The problem was that I added a table adapter that queried from my multiple tables, not just a single table. This tableAdapter looks like it just "decided" what columns to use for unique Contraints.

    To fix the issue, I had to go into the Dataset designer and search for "UniqueConstraint" until I found the one that was using two foreign key columns of the restraint instead of the one primary key.