
Keys: the most important decision
[Key] prevents duplicates. When you call TryAdd, Curiosity checks the key:
- Key exists → update the existing node
- Key is new → create a new node
Run the same connector twice, same source data → identical graph. That's idempotency.
[Key] public string Id { get; set; } // ✓ source ID — stable across runs
[Key] public Guid Id { get; set; } // ✗ Guid.NewGuid() — new node on every run
Rules:
- Use the source system's own ID
- Never use row order, sequence numbers, or random values
- Avoid composite keys — pick one stable identifier
No source ID? Build a deterministic one from stable fields:
// Hash a canonical string — brittle under schema changes, but better than random
string key = $"{row.Author}::{row.Title.ToLowerInvariant()}::{row.Date:yyyy-MM-dd}";
If at all possible, add a proper ID to the source instead.
Idempotency test: run the connector twice with no source changes. Node and edge counts must be identical.