Behavior of RelationshipsFollowDBForeignKeyConstraints

Posts   
 
    
DarkRoast
User
Posts: 42
Joined: 14-Jul-2010
# Posted on: 05-Aug-2010 00:55:28   

In the July 30th build of v3.0, I created a new project and set RelationshipsFollowDBForeignKeyConstraints to False. I then added a relational model from the Northwind database and reverse engineered the tables to entity definitions.

I expected that when the RelationshipsFollowDBForeignKeyConstraints is false, relationships would not be created automatically, however they do appear to have been created.

So the behavior is that relationships are always created initially and then never updated when the setting is false?

This thread also contains a good discussion, but I'm still not certain what it's really supposed to do.

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=18122&StartAtMessage=0&#101511

Also, the documentation states:

When set to false, relationships without a foreign key constraint in the new relational model data are left as-is and there aren't any new relationships created from foreign key constraints found in the new relational model data.

When starting a new project wouldn't all relational model data be considered "new"?

Thanks for any clarification.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Aug-2010 10:41:35   

When you start a project you are either:

1- Going DatabaseFirst approach, that's when database should be honored. IMHO if database relations exist, they should be ported to the model, as they will affect DAL operations.

2- Or going ModelFirst, then you would always define relations in the model that not yet there in gthe database, and so create and update sript are created to port these relations to the database.

The problems comes when mixing databaseFirst and modelFirst after creating a project, that's when the RelationshipsFollowDBForeignKeyConstraints comes to play, as it would decide which side is to follow.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 05-Aug-2010 10:48:42   

also, did you set it in the preferences and then created a new project, or did you set it in the preferences after you created a new project (so the project has the original default, true) or did you set it in the project properties?

Frans Bouma | Lead developer LLBLGen Pro
DarkRoast
User
Posts: 42
Joined: 14-Jul-2010
# Posted on: 06-Aug-2010 00:52:53   

That explanation makes sense, thanks.

I previously unchecked the RelationshipsFollowDBForeignKeyConstraints box in the LLBLGen Pro Preferences settings. I also set the value to False on the project properties box. Both settings were prior to adding the relational model.