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
コメント