Search code examples
kentico

changing a primary key field on a custom module class


I'm playing around with custom modules and classes (and UI). and I'm using a CV manager as an example. In this the Employee class is the parent and project is the child class (I also have an "Employee project" binding class).

I added the UI to insert projects so I can link them to employees later. However when creating a project I get a null exception as the PK column is empty. I checked the DB and the ProjectID column, doesn't have an identity set.

Can I change this via the Kentico admin UI? I can't remember if I selected the "is m:n table" option, when I created the class and cannot find that either.

If there is no option to do it via Kentico I'll do it in SQL management studio as I alreade have the binding class set up.


Solution

  • For binding classes, the documentation states specifically to "Manually set the class's ID fields as foreign keys in your database. See Create Foreign Key Relationships for more information." So you were on the right path, just finish by making your changes in SQL Server.