This project is read-only.

Confused: Added Primary Key Field Not Implemented

Feb 7, 2012 at 11:59 PM

This is under EFDAL. I have a table which previously used two fields as a primary key:

Field1 // part of primary key; not null
Field2 // part of primary key; not null
Field3 // not null

I recently changed the schema so that Field3 become part of the primary key. It's marked appropriately in the UI. No error was thrown on generation or running the install/update routine.

But the table definition in the database does not show Field3 as being part of the primary key.

If adding a field to an existing primary key definition is not allowed under nHydrate it should generate an error somewhere. Alternatively, if it is allowed, why is not updating?

Feb 13, 2012 at 2:13 PM

A new database install will be correct, but there was no update script for this. In the next version, it will generate a note in the change script with a commented primary key script. This is commented out because it may require manual intervention. You can only change the primary key of a table by dropping all relationships based on the key first. So the drop PK and re-add PK will be generated but as a comment. You may uncomment this script but you will have to do any relationship dropping and re-adding manually.