Blog Post

Setting PK Names in Redgate Data Modeler

,

A customer was testing Redgate Data Modeler and complained that it auto-generated PK names. I had to test and discover if I could make things better, and I could. This post shows how.

This is part of a series on Redgate Data Modeler.

Adding a New Entity

I can easily add a new Table to my diagram. I’ll click the New Table icon in the menu.

2025-12_0310

When I click in the design surface, I get a new table.

2025-12_0311

On the right, I see the table properties. I’ll need to fill these in.

2025-12_0312

Let’s change the name and add a few columns to this design. Note that for the first column I checked the PK box. This will be my primary key.

2025-12_0313

These are fine for now. Let’s now add adjust the PK.

Setting the Primary Key Constraint Name

If I click the three dots next to the PK check, I get a lot of properties for the column, not the PK.

2025-12_0317

I need to go below the columns. Notice the sections below the column area. One of these is for the Primary Key.

2025-12_0318

If I expand this, I can see the name field and columns. This was blank, but I typed in a name that makes sense to me. I could add columns as well here.

2025-12_0314

Checking the SQL

If I click the Generate SQL button from the top menu, I get a dialog.

2025-12_0315

I click the Save button, which will save this to the file specified. I’ve set this in my project before (which is another post), but I am trying to save to a single file for my code that updates.

When I open this code, here is the relevant part of the file. Note that my PK is named appropriately.

2025-12_0316

What happens if I don’t do that? I added another table, marked a PK, and this is what I see. First, my table (there is nothing set under the PK tab):

2025-12_0319

The SQL code shows a standard similar to mine, but different. I think a lot of people use the underscores, so I’m not surprised this is the setting.

2025-12_0320

Not bad, but not what I want.

Summary

The Redgate Data Modeler is a basic tool for now, but it does let you set a specific PK name if you want to enforce a standard. This can’t be set as a default, but I’ve submitted a feature request to change this.

At least I can customize what I want as I build something.

Give Redgate Data Modeler a try and see if it helps you and your team get a handle on your database.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating