You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RavenDB-25154 - Document TrackingMode session option and TrackAllEntities feature
- Update SessionOptions table in opening-a-session to include TrackingMode parameter
- Rewrite disable-tracking page to cover TrackingMode enum (NoTracking, TrackAllEntities, Default)
- Add TrackAllEntities section explaining automatic change tracking for all loaded entities
- Update main disable-tracking page title and description to reflect broader tracking configuration scope
@@ -5,20 +5,123 @@ import CodeBlock from '@theme/CodeBlock';
5
5
6
6
<Admonitiontype="note"title="">
7
7
8
-
* By default, each session tracks changes to all entities it has either stored, loaded, or queried for.
9
-
All changes are then persisted when `SaveChanges` is called.
8
+
* By default, each session tracks changes to all entities it has either stored, loaded, or queried for.
9
+
All changes are then persisted when `SaveChanges` is called.
10
10
11
-
* Tracking can be disabled at various scopes:
12
-
for a specific entity, for entities returned by a query, for all entities in a session, or globally using conventions.
11
+
* The session's tracking behavior can be configured using the `TrackingMode` option in `SessionOptions`.
12
+
13
+
* Tracking can also be disabled at more granular scopes:
14
+
for a specific entity, for entities returned by a query, or globally using conventions.
13
15
14
16
* In this article:
15
-
*[Disable tracking changes for a specific entity](../../../../client-api/session/configuration/how-to-disable-tracking.mdx#disable-tracking-changes-for-a-specific-entity)
*[Track all entities](../../../../client-api/session/configuration/how-to-disable-tracking.mdx#track-all-entities)
16
19
*[Disable tracking all entities in session](../../../../client-api/session/configuration/how-to-disable-tracking.mdx#disable-tracking-all-entities-in-session)
20
+
*[Disable tracking changes for a specific entity](../../../../client-api/session/configuration/how-to-disable-tracking.mdx#disable-tracking-changes-for-a-specific-entity)
|**Default**| Standard tracking. The session tracks changes only to entities that are stored, loaded, or queried. Modified entities are persisted when `SaveChanges` is called. |
33
+
|**NoTracking**| Tracking is disabled. Entities are not tracked. `Store` is not available. Each `Load` or `Query` call creates new entity instances. Equivalent to the deprecated `SessionOptions.NoTracking = true`. |
34
+
|**TrackAllEntities**| Extended tracking. In addition to the default behavior, the session records the change vectors of **all** entities it encounters (loaded, queried, or included). On `SaveChanges`, these change vectors are sent to the server, which verifies that none of the tracked entities were modified by another session. A `ConcurrencyException` is thrown if a conflict is detected. |
The `SessionOptions.NoTracking` boolean property is deprecated and will be removed in a future major version.
52
+
Use `SessionOptions.TrackingMode` instead. Setting both `NoTracking` and `TrackingMode` on the same `SessionOptions` object will throw an `InvalidOperationException`.
53
+
54
+
</Admonition>
55
+
56
+
<Admonitiontype="info"title="Limitation">
57
+
58
+
`TrackingMode.TrackAllEntities` is not compatible with `TransactionMode.ClusterWide`.
59
+
Setting both will throw an `InvalidOperationException`.
60
+
61
+
</Admonition>
62
+
63
+
64
+
65
+
## Track all entities
66
+
67
+
* When `TrackingMode` is set to `TrackAllEntities`, the session tracks the change vectors of all entities it encounters -
68
+
not only those that are modified.
69
+
* On `SaveChanges`, the session sends the tracked change vectors to the server as part of the batch operation.
70
+
* The server validates that none of the tracked entities were modified by another session since they were loaded.
71
+
* If a tracked entity was modified externally, a `ConcurrencyException` is thrown and none of the changes in the batch are persisted.
72
+
* This provides **session-wide optimistic concurrency** - ensuring that the data you read has not changed by the time you save.
|**Database**|`string`| The Session will operate on this database,<br/>overriding the Default Database. |`null` - the Session operates on the Default Database |
76
-
|**NoTracking**|`bool`|`true` - The Session tracks changes made to all entities it loaded, stored, or queried for.<br/>`false` - Tracking will be turned off.<br/>Learn more in [Disable tracking](../../../client-api/session/configuration/how-to-disable-tracking.mdx)|`false`|
76
+
|**TrackingMode**|`TrackingMode`| Configure the session's entity tracking behavior:<br/>`Default` - Standard tracking (track only modified entities).<br/>`NoTracking` - Disable tracking for all entities.<br/>`TrackAllEntities` - Track change vectors of all loaded entities; on `SaveChanges`, the server verifies none were modified externally, throwing a `ConcurrencyException` if they were.<br/>Learn more in [Configure tracking](../../../client-api/session/configuration/how-to-disable-tracking.mdx)|`Default`|
77
+
|**NoTracking**_(deprecated)_|`bool`|_Deprecated. Use `TrackingMode` instead._<br/>`true` - Tracking will be turned off.<br/>`false` - Default tracking behavior.<br/>Learn more in [Configure tracking](../../../client-api/session/configuration/how-to-disable-tracking.mdx)|`false`|
77
78
|**NoCaching**|`bool`|`true` - Server responses will Not be cached.<br/>`false` - The Session caches the server responses.<br/>Learn more in [Disable caching](../../../client-api/session/configuration/how-to-disable-caching.mdx)|`false`|
78
79
|**RequestExecutor**|`RequestExecutor`| ( _Advanced option_ ) <br/>The request executor the Session should use. |`null` - the default request executor is used |
79
80
|**TransactionMode**|`TransactionMode`| Specify the Session's transaction mode<br/>`SingleNode` / `ClusterWide`<br/>Learn more in [Cluster-wide vs. Single-node](../../../client-api/session/cluster-transaction/overview.mdx#cluster-wide-transaction-vs-single-node-transaction)|`SingleNode`|
0 commit comments