Hi, Readers.
Today I would like to briefly talk about how to manage Database Access Intent in Business Central.
Business Central can be set up to use read-only replicas of the primary (read-write) database. Using the database replica reduces the load on the primary database. In some cases, it will also improve the performance when viewing data in the client. Replicas are beneficial for objects, like reports, queries, and API pages, that are used for viewing data only, not modifying data.
When objects run, the database access intent determines whether to use a read-only replica, if one is available, or the primary database. Reports, API pages, and queries are developed with a predefined database access intent (seeĀ DatabaseAccessIntent property).
DataAccessIntent Property: Sets the data access intent of the page.
Applies to:
Value | Available or changed with | Description |
---|---|---|
ReadOnly | runtime version 1.0 | Intent to access records, but not to modify them. Read-only pages are run against a replica of the database leading to improved performance, but preventing modifications to the database records. |
ReadWrite | runtime version 1.0 | Intent to access and modify records. |
PS: It only applies to pages of the type API. For such, TheĀ Editable propertyĀ must be set toĀ false.
As a super user or administrator, you can change the database access intent on reports, pages of the type API in the web client, and queries to improve performance of the service.
Letās see more details.
Choose the Tell me icon, enterĀ Database Access Intent List, and then choose the related link.
The page Database Access Intent List (9880, List) lists all reports, pages, and queries. ThisĀ page lets you override the predefined database access intent for objects when theyāre run.
TheĀ Access IntentĀ column includes one of the following values:
You can change theĀ Access IntentĀ field for the objects.
Setting | Description |
---|---|
Default | Indicates that the object uses the predefined database access intent. |
Allow Write | Sets the object to use the primary database, allowing the user to modify data. |
Read Only | Sets the object to use the database replica, which means that the user can only view data, not change data. |
For example,
PS: If you change the Access Intent value to a value other than Default, the data will be stored in table 2000000205 āObject Access Intent Overrideā
Using ReadOnly might also improve performance when viewing objects. ReadOnly works as a hint for the server to route the connection to a secondary (read-only) replica, if one is available. When a workload is executed against the replica, insert/delete/modify operations arenāt possible. If any of these operations are executed against the replica, an exception is thrown at runtime.
Post (Insert):
{
Ā Ā Ā Ā āerrorā:Ā {
Ā Ā Ā Ā Ā Ā Ā Ā ācodeā:Ā āBadRequest_MethodNotAllowedā,
Ā Ā Ā Ā Ā Ā Ā Ā āmessageā:Ā āEntityĀ doesĀ notĀ supportĀ insert.Ā Ā CorrelationId:Ā Ā 2e523d47-880e-4a05-8244-1ba5fa43f36d.ā
Ā Ā Ā Ā }
}
Delete:
{
Ā Ā Ā Ā āerrorā:Ā {
Ā Ā Ā Ā Ā Ā Ā Ā ācodeā:Ā āBadRequestā,
Ā Ā Ā Ā Ā Ā Ā Ā āmessageā:Ā āEntityĀ doesĀ notĀ supportĀ delete.Ā Ā CorrelationId:Ā Ā 8df94c3a-5bde-4f70-988a-cb7480676f14.ā
Ā Ā Ā Ā }
}
Patch (Modify):
{
Ā Ā Ā Ā āerrorā:Ā {
Ā Ā Ā Ā Ā Ā Ā Ā ācodeā:Ā āBadRequest_MethodNotAllowedā,
Ā Ā Ā Ā Ā Ā Ā Ā āmessageā:Ā āEntityĀ doesĀ notĀ supportĀ modifyingĀ data.Ā Ā CorrelationId:Ā Ā 023edc16-5a4a-404f-aee5-9541cf370a75.ā
Ā Ā Ā Ā }
}
Test video: Patch (Modify)
Note:
If an object that is editable, like the Customer Card, is set toĀ Read Only, the primary database will still be used, regardless of the access intent, allowing users to make changes as normal.
Give it a try!!!š
PS: You can find more details about Managing Database Access Intent in MS Learn (Docs).
END
Hope this will help.
Thanks for reading.
ZHU
ć³ć”ć³ć