I want to add a column to the model, but I do not want to add it to the database. What do I do?
We have created the Extension container functionality for that. To use this functionality you need to:
- Add the Extensions (or any other name) field of the nvarchar(max) type to the table
- Add a column to the model and specify its name in the Extension container field
- Add attributes with the Extension flag
After that, all attributes with the Extension flag will be serialized and stored in the Extension container in the JSON format. Please, note:
- DWKit ORM fully supports such columns; however, you may encounter difficulties when directly accessing these fields through the database server.
- This functionality works in MS SQL Server 2017+ and Postgres 9.5+.
You can get acquainted with this functionality in the HRM solution built with DWKit. There's the Document table which stores several types of documents (business trip, compensation, sick leave, etc.). Each of these document types contains a set of additional fields. These fields are stored as a JSON object in the Extension column. When forming a request to the database DWKit automatically serializes and deserializes this object. Here's the BusinessTrip data model sample. All fields with the Extension flag are additional and are stored in a JSON object in the Extension field, but you can work with them as if they were regular attributes in the application.