Skip to content

Commit f4cffd1

Browse files
authored
Added note about non-primary-key GUIDs. (#792)
* Added note about non-primary-key GUIDs.
1 parent bd84c4c commit f4cffd1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

docs/contributing/code-style/csharp.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,17 @@ timestamp information for sequential ordering.
180180
// Good
181181
var id = CoreHelpers.GenerateComb();
182182

183-
// Bad
183+
// Bad - for entity IDs, don't use Guid.NewGuid()
184184
var id = Guid.NewGuid();
185185
```
186186

187+
:::note
188+
189+
For non-primary-key GUIDs (e.g. correlation IDs or other values not used as a database primary key),
190+
`Guid.NewGuid()` is acceptable.
191+
192+
:::
193+
187194
Entities should implement `SetNewId()`:
188195

189196
```csharp

0 commit comments

Comments
 (0)