How to remove/exclude field from model but keep the database column?

Posts   
 
    
rbrown
User
Posts: 36
Joined: 11-Jun-2008
# Posted on: 08-May-2024 19:27:39   

There is a database column which I want to remove/exclude from the model. I want to keep the column in the database, for future reference, but it's no longer needed in the code. I deleted the field from the Entity using the "Remove selected" button, however it keeps coming back each time I sync with the database (SQL Server). Is there a way to mark this as hidden/deleted from the model such that it doesn't keep getting re-added each time I sync? Note this particular field is a nullable FK so the designer also keeps re-adding the relation/navigator as well. I see there is a context menu for "Toggle Marked for Deletion Flag" which seems relevant, but this is greyed out for me.

Designer v5.11.1 (also happens in v5.10) SQL Server 15.0.2000.5 Adapter

Walaa avatar
Walaa
Support Team
Posts: 14982
Joined: 21-Aug-2005
# Posted on: 08-May-2024 19:58:19   

By default for normal fields, this is not the case.

But as you said this is a FK field, and the designer automatically sync relations with the database, you can disable this sync, but any other relation added in the db will not be picked by the designer and you will need to define it manually.

In project settings, uncheck "relationships follow dbforeign key constraints", found under Entity Model \ Database First Development.

rbrown
User
Posts: 36
Joined: 11-Jun-2008
# Posted on: 09-May-2024 16:14:11   

Ah yes that makes sense. I have now deleted the relation from SQL, and the designer no longer tries to re-add the field when I sync. This solves my problem. Thanks!