I've read that in Entity Framework Core HiLo pattern "Hi" part is managed by database and "Lo" part is managed by Entity Framework in memory.
How does Entity Framework generate "Lo" part without round-trip to database?
How persist the "Lo" value between requests?
And most important, is this pattern thread safety?
The HiLo generator works by occasionally reserving a block of IDs on the server then using IDs from that block on the client as needed. You only need to hit the database when reserving the block, so if your block size is 100, you'll round-trip every 100 IDs.
Yes, it's safe to have multiple contexts assigning IDs concurrently since the block is atomically assigned by the database server. Each
DbContext instance will have its own block.