Sometimes it makes sense for me to create a view to use with BLD instead of the table directly. This is usually because I also want to include a calculated field that is best calculated in the database. For example: a “CanBeDeleted” bit value for records that don’t have any associated children records.
I typically create a view, then use LLBLGen to generate an entity from that new view. There are some things I need to remember when using this with BLD (but most of these are really LLBLGen tasks):
- Mark a primary key for the view in LLBLGen, or records won’t be editable (and in fact the “Edit” button won’t appear in your UI).
- Identify any relationships to other tables within the view in LLBLGen. Otherwise foreign keys won’t work.
- I prefer to create entities for the table entity also and I put most or all of my annotation attributes there. Then I use <AttributeSource> on the view metadata to copy the attributes from the entity to the view metadata.
- <AttributeSource> copies Data attributes (business rules) but not structural attributes, like AssociationDbInfo (used for foreign keys).