-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification for GUID generation behavior in EF Core 5.0 for SQL Server #2947
Comments
@felinepc This statement:
is intended to indicate that |
Thanks. Just to clarify, is |
SequentialGuidValueGenerator is the default when using the SQL Server provider. This hasn't changed--it's been this way since 1.0. |
Yeah, the original intention was to say that the SQL Server algorithm would be used (but on the client-side). Since then, investigation in dotnet/efcore#19124 (which contains lots of other relevant info) has shown that EF Core isn't actually implementing the SQL Server algorithm, though it's still generating optimal sequential GUIDs. We should indeed update. |
* Improvements to the value generation page * Create new page on SQL Server value generation, with information on IDENTITY, seed/increment, etc. * Delete "explicit values for generated properties" page, moving relevant content to the new SQL Server page and to the fixed-up generated properties page. Fixes #2980 Fixes #2947 Closes #2999 Co-authored-by: Andriy Svyryd <AndriySvyryd@users.noreply.github.com>
Ask a question
If a developer's goal is to have “sequential” GUID primary keys generated for faster performance, either by EF Core or the SQL Server’s NEWSEQUENTIALID, what is the expected behavior in EF Core 5.0 and what is the best practice?
This documentation says:
Does this mean if we don’t configure anything on a GUID property at all, EF Core 5 will automatically use its optimized sequential GUID generator to generate a non-temporary sequential GUID that will be saved to the DB? Or do we have to specify ValueGeneratedOnAdd?
But then there is this other documentation which says something different:
This seems to contradict the first link, which said the GUIDs would be generated on client side.
Some clarifications on this behavior and best practice would be appreciated, since we’d often opt to use GUID instead of int for primary keys to avoid giving away business information to end users.
It would also be nice to know the best approach to take when we do want non-sequential, random GUIDs for properties that are security-sensitive.
Thank you!
Include provider and version information
EF Core version: 5.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 10 Pro
IDE: Visual Studio 2019 16.8.3
The text was updated successfully, but these errors were encountered: