Unique Constraints, Foreign Keys and Navigation Properties

Posts   
 
    
Collh
User
Posts: 3
Joined: 27-Apr-2016
# Posted on: 13-Sep-2018 16:18:01   

Hello,

I am using LLBLGen with the MS SQL Server against a database that I cannot control. The database has many lookup tables that have a Guid PK AND and column that is defined as following

  • integer
  • Identity
  • Unique constraint LLBLGen 5.2 doens't recognize these FKs and doesn't provide a navigation property to the parent table. Also, I'm unable to add model-only FKs (which is a great feature!), as the table already has a PK that is duly offerd!

Is it possible to have LLBLGen generate the needed navigation properties?

Thank you for your help!

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 13-Sep-2018 17:50:54   

LLBLGen 5.2 doens't recognize these FKs and doesn't provide a navigation property to the parent table.

What FKs?

Do you mean, GUID PKs are not used for relations in the database, and other tables are referencing the other UC column?

Collh
User
Posts: 3
Joined: 27-Apr-2016
# Posted on: 13-Sep-2018 17:54:33   

Exactly!

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 13-Sep-2018 23:26:54   

In the Designer, you can un-check "Is PK" for the GUID PK, and mark it for the UC field. Then you can define a custom (model-only) relation between the 2 entities.

As a result, you will get the Navigators.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39589
Joined: 17-Aug-2003
# Posted on: 14-Sep-2018 08:21:00   

You're likely using database first development, so also make sure you're UNchecking the setting Entity Model -> Database First Development -> Identifying fields follow dbprimary key constraints, otherwise a refresh will reset the changed pk fields.

Frans Bouma | Lead developer LLBLGen Pro