After upgrading, view columns have IsOptional=true

Posts   
 
    
Posts: 4
Joined: 24-May-2018
# Posted on: 30-Oct-2018 01:19:17   

I am in the process of upgrading from v2.6 to v5.4.3. I got the .lgp file converted to a .llblgenproj file. I opened it in v5.4.3. Then I performed a "Sync Relational Model Data." Note, we are using database first. After performing the sync, nearly every column of every view was converted to IsOptional=true. I realize that databases don't really have the concept of nullability with views. But I don't see why the value of IsOptional was changed instead of preserved, like it was with v2.6.

The result of this is that the generated entities will have nullable properties when they used to not be nullable. This will break my code.

What do I do about this? If I know a column can't ever be null, can I mark it as IsOptional=false? And if I do that will that setting be preserved if I sync again? If so, do I do this to the entities in Project Explorer? I don't seem to be able to do it in Catalog Explorer (everything appears to be read-only). And if I do it in Project Explorer, will I get errors or warnings because the entities in Project Explorer don't match Catalog Explorer.

Thanks for the help.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Oct-2018 06:34:41   

dweber@terpsys.com wrote:

I am in the process of upgrading from v2.6 to v5.4.3. I got the .lgp file converted to a .llblgenproj file. I opened it in v5.4.3. Then I performed a "Sync Relational Model Data." Note, we are using database first. After performing the sync, nearly every column of every view was converted to IsOptional=true.

Did this happen just after the migration or after the relational data model?

dweber@terpsys.com wrote:

What do I do about this? If I know a column can't ever be null, can I mark it as IsOptional=false? And if I do that will that setting be preserved if I sync again?

No, if you manually change the attribute (Optional) it should be seen by a manual change and it will be preserved after a Relational Model Sync.

dweber@terpsys.com wrote:

And if I do it in Project Explorer, will I get errors or warnings because the entities in Project Explorer don't match Catalog Explorer.

Yes, you will get warnings (no errors) as the metadata obtained from your DB doesn't match your model. However you may proceed with code generation, as they are just warnings.

David Elizondo | LLBLGen Support Team
Posts: 4
Joined: 24-May-2018
# Posted on: 30-Oct-2018 12:49:40   

Thank you, daelmo. The change of IsOptional happened as a result of performing a sync while in v5.4.3 of the designer Prior to performing the sync, everything was fine. I suppose in v2.6, the designer assumes columns in views are IsOptional=false but in v5.4.3, it assumes they are IsOptional=true?

So, to clarify, you're suggesting that I go into Project Explorer and mark columns as IsOptional=false if I know then can never be null. Then if I sync in the future, they will remain that way?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Oct-2018 18:36:03   

This change was introduced in the Designer v.4.2

Change wrote:

Catalog Refresher: If an element was mapped onto a view, IsOptional values for fields of the element weren't synced with the mapped target view's fields's Nullable values. This was by design. This has been changed to sync IsOptional with Nullable during a refresh of the catalog metadata if the element field's IsOptional value was equal to the target field's Nullable value. Previously this sync was only performed for tables, not views. As before for tables, if the element's field's IsOptional value differs from the old target field's Nullable value (so the user has changed the value of IsOptional at some point) the new view's field's Nullable value is ignored, to prevent overwriting a manual change